Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple NSFetchedResultsController - didChangeObject
    primarykey
    data
    text
    <p>I have a <code>UITableView</code> which uses 2 <code>NSFetchedResultsControllers</code>. Each <code>NSFetchedResultsController</code> has only one section. However, the table has 4 sections. I populate the 4th section of the table with the results of one of the <code>NSFetchedResultsControllers</code>. Everything works fine so far. But if the user deletes the first cell on the first section, the <code>NSFetchedResultsControllers</code> are changed. The rows in the last section of the table might be deleted. When this method is called:</p> <pre><code>- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { UITableView *tableView = self.tableView; switch(type) { case NSFetchedResultsChangeInsert: [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; break; case NSFetchedResultsChangeDelete: NSLog(@"section: %d, row: %d", [newIndexPath section], [newIndexPath row]); [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; break; ... } </code></pre> <p>The section is always 0 because it's the section of the <code>NSFetchedResultsControllers</code>. Thus, the section doesn't match the correct one on the table view.</p> <p>Is there a workaround? I would basically like to change the section of a <code>NSFetchedResultsController</code> to 3 instead of 0.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload