I am using a PFQueryTableViewController to display data from PFObjects but I want to create an alternative cell for when there are no objects to show. I tried doing this but when I return 1 in numberOfRowsInSection, I get the following error: * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
I'm not sure what to do but here's the code that I have:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([self.objects count] != 0){
// Return the number of rows in the section.
return [self.objects count];
}else{
return 1;
}
}
I figured it out using the answer to this question: https://www.parse.com/questions/adding-static-cells-to-the-beginning-of-a-pfquerytableviewcontroller