Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

khartley

macrumors newbie
Original poster
May 13, 2011
1
0
I have to wait for a return from a call to a web service before I can populate my data source with the correct data (an array of images). In the method that I have created in the viewController I pass in that array, getting the datasource populated and ready for its display. After populating the datasource, I call [tableView reloadData] - but in the debugger, it's like skipping over a comment - nothing ever happens. Does this behavior indicate to any of you something that I should check? It seems like I don't have something quite right (obviously), but I can't think of what!
 
I have to wait for a return from a call to a web service before I can populate my data source with the correct data (an array of images). In the method that I have created in the viewController I pass in that array, getting the datasource populated and ready for its display. After populating the datasource, I call [tableView reloadData] - but in the debugger, it's like skipping over a comment - nothing ever happens. Does this behavior indicate to any of you something that I should check? It seems like I don't have something quite right (obviously), but I can't think of what!

Let's start with the stuff that I always forget to do!

  • Is your table view actually initialized?
  • Is your view controller set to be the delegate and dataSource of your table view?

Usually, I add an NSMutableArray instance variable to my view controller; call it tableItems, or something. Make sure you initialize it in your view controllers -init method (whichever you happen to be using). Return the -count of the mutable array from -tableView:numberOfRowsInSection:, and do the similar, proper thing in -tableView:cellForRowAtIndexPath:

When your async network operation returns, do something like this:

Code:
[tableItems addObjectsFromArray:myNSArray];
[self.tableView reloadData];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.