I finally solved my problems by implementing my own save routine:
[_localMOC performBlockAndWait:^{
NSError *errLoc=nil;
if (![self.mainMOC obtainPermanentIDsForObjects:@[[[_mainMOC insertedObjects] arrayByAddingObjectsFromArray:[_mainMOC updatedObjects]]] error:&errLoc]) {
NSLog(@" ... ");
}
if (![_localMOC save:&errLoc]) {
NSLog(@" ... ");
}
[_mainMOC performBlockAndWait:^{
NSError *errMain=nil;
if (![_mainMOC save:&errMain]) {
NSLog(@" ... ");
}
}]
}];
Note that _mainMOC
is being observed from the AppDelegate
and will have its changes asynchronically persisted to disk by his _saveMOC
parent.