views:

2129

answers:

2

I defined an array for tableView's listData.

NSArray *array = [[NSArray alloc] initWithObjects:@"Sleep", @"Bashful", @"Happy", nil];
self.listData = array;

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
cell.text = [listData objectAtIndex:row];

Now I want to add more data to the tableview. How to connect another data to it so when I click a button the array will be @"A", "B", "C", "D", nil?

+1  A: 

The easiest way to do this is to use the NSMutableArray with insertObjetcAtIndex or addObject:

NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:@"Sleep", @"Bashful", @"Happy", nil];
[array insertObject:@"XYZ" atIndex:3];
[array addObject:@"ABC"];
Alexandre L Telles
I want to add some new objects later(after viewDidLoad method). How to call the UITableView's data source method again to reload the new data?
iPhoney
You can call the method reloadData from your UITableView:[table reloadData];
Alexandre L Telles
A: 

How can I add a object from "titleForState:UIControlStateNormal"?

thanks

just solved.