I am trying to use (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object to customize the display of PFObject data in a PFQueryTableViewController. So I construct my PFQuery object in (PFQuery *)queryForTable in my PFQueryTableViewController delegate that is supposed to obtain the multiple objects in an NSArray.
I thought that parse.com is supposed to then send/call (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object once for each of the objects returned. However, I find that it keeps returning the same object multiple times.
Thus, for example, instead of 3 different objects for the 3 times (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object is called, I get the same object. But it is not a problem with the data or the query, because at the end of (PFQuery *)queryForTable , just before
return query;
I tried
[query findObjectsInBackgroundWithBlock:^(NSArray *resultsNow,NSError *error) {NSLog(@"We have the following: %@", resultsNow);}];
sleep(5);
and this shows the 3 objects obtained correctly. How is it that the exact same query when handled by PFQueryTableViewController calling (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object 3 times, instead of sending the 3 objects one by one, it sends the first one 3 times?
In response to Wain's questions, I added some answers in the comments, but also the following seems relevant:
- (PFObject *)objectAtIndex:(NSIndexPath *)indexPath {
// overridden, since we want to implement sections
if (indexPath.section < self.objects.count) {
return [self.objects objectAtIndex:indexPath.section];
}
return nil;
}
objectsDidLoad:/ available inobjects?self.tableView.tableHeaderView = nil;andself.tableView.scrollEnabled = YES;that shouldn't make a difference, but I'll explore that more.<NSIndexPath 0x1e86b5e0> 2 indexes [0, 0],<NSIndexPath 0x1e84db30> 2 indexes [1, 0]and<NSIndexPath 0x1d5ce8f0> 2 indexes [0, 0]objectsDidLoad:before the cells are updated.