uitableviewnsxmlparser

UITableView LifeCycle


I have an Objective C - iPhone Application I am writing, and I think I may be confused on the lifecycle of the UITableView process. The issue is that in my application. I have a WebService I am calling. I parse the response with NSXML Parser and put the values I am looking for in an Array. I know up to this point the values are their, I can see it. But it looks like the call to call to display the cells happens before the Parser is parsing it, so it never shows up.

I have tried reloading the tableview, and difference points, but it never calls the

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

or

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

what can I do and where to get these to be called after the NSXML Parser has parsed the XML and put it in an array.

What actually triggers the UITableView to go to the data source and display the cells.


Solution

  • When the NSXML parser is finished you should call the UITableView reloadData method which will force a redraw of your tableview. Your view controller should implement the UITableViewDataSource protocol which will initialize the tableview based on the Array that you populated while parsing the XML.

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html