Very simple situation. Not sure why it\'s causing an issue.
I have a view that creates a new NSManagedObject in a child NSManagedObjectContext. When the user presses \"
Because the child does not get updated back from the parent MOC. The parent MOC will update its own instance of the NSManagedObject
with a permanent ID but that change will not be pushed down to the instance of that NSManagedObject
belonging to the child MOC.
I do not use -objectID
in this situation. It has some uses but it is not a permanent uniqueID. In a situation like this, I prefer to add my own uniqueID to the entity and then fetch it from the main context.
You could also just listen for the context save notifications or use an NSFetchedResultsController which will receive updates.
Have you tried obtaining the permanent ID's for your objects? I've had success sharing NSManagedObjectID
's between contexts by calling
NSError *error = nil;
[self.context obtainPermanentIDsForObjects:@[object1, object2]
error:&error];
followed by my save method. I structure my contexts in such a way that there is an I/O context which is the parent to my 'read context' (context used for my main thread activity) which is the parent to my background task contexts. Save in this case propagates all the way up the chain.