Next page crashes using PFQueryTableViewController based on section (ala Anypic)

In a PFQueryTableViewController with paging enabled and which displays sections:

 self.paginationEnabled = YES;
 self.pullToRefreshEnabled = YES;
 self.objectsPerPage = 3;

      

I am getting this error when I click the next page button:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 3 from section 0 which only contains 1 rows before the update

      

I replaced the row based data display with this section based data:

- (PFObject *)objectAtIndexPath:(NSIndexPath *)indexPath {
  if (indexPath.section < self.objects.count) {
    return [self.objects objectAtIndex:indexPath.section];
  }
  return nil;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  NSInteger sections = self.objects.count;
  if (self.paginationEnabled && sections != 0)
    sections++;
  return sections;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  return 1;
}

      

How can a pfquerytableview controller be kept based on a section if the next page method tries to delete the cell of the next page, which, if I'm not mistaken, should be the last cell of the table (instead of the last section). This behavior seems to work in other examples given by Parse, such as the Anypic app.

+3


source to share





All Articles