Note that there are some explanatory texts on larger screens.

plurals
  1. PONSFetchedResultsController attempting to insert nil object?
    primarykey
    data
    text
    <p>For a long time I've been getting a strange bug where most of my table view becomes black (only a few cells remain <a href="http://cl.ly/LFlS" rel="nofollow">http://cl.ly/LFlS</a>) and in other views (connected to the same MOC) some other visual glitches appear: <a href="http://cl.ly/LH3c" rel="nofollow">http://cl.ly/LH3c</a> (notice the duplicate section headers). I always figured it was a bug with CoreData but I never got to reproduce it until today while it was hooked to the debugger. Here's the exception I got right before it happened:</p> <blockquote> <p>CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. <em>*</em> -[__NSArrayM insertObject:atIndex:]: object cannot be nil with userInfo (null)</p> </blockquote> <p>It stopped on the <code>[tableView endUpdates]</code> line in my <code>controllerDidChangeContent:</code> method. Then if I click continue, the app doesn't crash, but user interaction becomes extremely sluggish. I looked all over the place as of what might be the cause of that exception and couldn't find anything. Any clue?</p> <p>My NSFetchedResultsController change handling looks pretty much like Apple's boilerplate. The init of my NSFRC looks like this:</p> <pre><code>NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Artist" inManagedObjectContext:[SWDataManager sharedManager].mainObjectContext]; [request setEntity:entity]; [request setFetchBatchSize:100]; NSSortDescriptor *sortByName = [[NSSortDescriptor alloc] initWithKey:@"sortName" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]; [request setSortDescriptors:@[sortByName]]; fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:mainObjectContext sectionNameKeyPath:@"firstLetter" cacheName:nil]; fetchedResultsController.delegate = self; [self refreshDataSource]; // set fetch request predicate and call performFetch on NSFRC return fetchedResultsController; </code></pre> <p>EDIT: I can add that this definitely happened after that a bunch of objects got deleted from my MOC and therefore from the table view.</p> <p>As requested, my <code>controllerDidChangeContent:</code> code:</p> <pre><code>- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { [self.tableView endUpdates]; // this updates the section index and footer cell and other kind of stuff [self performSelector:@selector(layoutSpecialCells) withObject:nil afterDelay:0.3]; } </code></pre>
    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.
 

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