I think you MUST create your backgroundContext from within your backround process.
and you need to listen for the notification sent by the backgroundContext:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mergeChanges:) name:NSManagedObjectContextDidSaveNotification object:self.backgroundContext];
in my case runupdate is run in the background process:
- (void) runUpdate {
NSManagedObjectContext *managedContext = [[NSManagedObjectContext alloc] init];
managedContext.persistentStoreCoordinator = ...;
[updateController registerBackgroundMoc:managedContext];
//do all update stuff
NSError *error;
if (![managedContext save: &error] {
...
}
[updateController unregisterBackgroundMoc:managedContext];
}
in my updateController I did the following:
- (void) registerBackgroundMoc: (NSManagedObjectContext *) updateMoc {
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mergeChanges:) name: NSManagedObjectContextDidSaveNotification object: updateMoc];
}
- (void) unregisterBackgroundMoc: (NSManagedObjectContext *) updateMoc {
[[NSNotificationCenter defaultCenter] removeObserver: self name: NSManagedObjectContextDidSaveNotification object: updateMoc];
}