I've spent a couple of hours tonight trying to create a setup whereby I have three managed object contexts - one attached to my application's delegate, one in an NSObject
subclass responsible for UITableView
updates (via an NSFetchedResultsController
) and one in an NSOperation
subclass.
I can get the changes from the NSOperation
subclass to the app delegate to flow through just fine by observing NSManagedObjectContextDidSaveNotification
, and firing off mergeChangesFromContextDidSaveNotification:
on my main thread, but when I try to do the same thing from my UITableView
data source, I get the following exception:
2010-02-19 02:00:39.750 MyApp[44687:207] Serious application error. Exception was caught during Core Data change processing: *** -[NSCFArray initWithObjects:count:]: attempt to insert nil object at objects[0] with userInfo (null)
2010-02-19 02:00:39.750 MyApp[44687:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray initWithObjects:count:]: attempt to insert nil object at objects[0]'
I'd appreciate any advice - all of my previous designs involving Core Data managed object contexts have been very simple 1:1 sync scenarios. Is what I'm proposing even possible?