NSFetchedResultsController attempting to insert nil object
From an Apple Technical Support Engineer:
To protect the integrity of the datastore, Core Data catches some exceptions that happen during its operations. Sometimes this means that if Core Data calls your code through a delegate method, Core Data may end up catching exceptions your code threw.
Multi-threading errors are the most common cause of mysterious Core Data issues.
In this case, Core Data caught an exception through your controllerDidChangeContent:
method, caused by trying to use insertObject:atIndex
.
The most likely fix is to ensure that all your NSManagedObject
code is encapsulated inside performBlock:
or performBlockAndWait:
calls.
In iOS 8 and OSX Yosemite, Core Data gains the ability to detect and report violations of its concurrency model. It works by throwing an exception whenever your app accesses a managed object context or managed object from the wrong dispatch queue. You enable the assertions by passing -com.apple.CoreData.ConcurrencyDebug 1
to your app on the command line via Xcodeʼs Scheme Editor.
Ole Begemann has a great writeup of the new feature.