views:

48

answers:

3

I have a UITableViewController that when loaded gets data from a web-service and stores it locally in an NSMutableArray, once that is loaded I need to loop through that data to build my table cells.

I have all of the code for looping through my array working fine I just need to know how to fire my controller to rebuild the table so my it displays my data.

+2  A: 
[self.tableView reloadData];
chrissr
I tried the above and it just crashes, where do I setup the table view to have a datasource and will a NSMutableArray work for that?
Slee
it is an NSMutableArry of objects
Slee
Have you implemented your UITableViewDataSource methods to use your NSMutableArray? http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewDatasource_Protocol/Reference/Reference.html
chrissr
I think it's the link below I need, where do implement this? In the table view controller itself? http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TableView/Tasks/UsingTableDataSource.html
Slee
A: 

After saving the datas in mutatable array after calling webservices, call tableview reloadData

[self.tableView reloadData];



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return [datas count];
}

Make sure that you update the mutable array "datas" value after storing content in mutable array, such as datas will have the web service contents.

Here is sample program of parsing and displaying the parsed content in table, you can refer it how they are reloading their table after parsing

All the best.

Warrior
A: 

I ended up following the instructions here for creating a UITableViewDataSource class, works like a champ!

UITableViewDataSource simplified

Slee