Call to tableview reloadData skips over

Discussion in 'iOS Programming' started by khartley, May 16, 2011.

  1. macrumors newbie

    Joined:
    May 13, 2011
    #1
    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!
     
  2. macrumors member

    Joined:
    Feb 1, 2007
    Location:
    Seattle, WA
    #2
    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];
    
     

Share This Page