Reputation: 1100
In Core Data with NSManagedObjectContext: If I have a parent and a child context, when I save the child context do I also need to save the Parent Context?
i.e.
NSManagedObjectContext *childContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
childContext.parentContext = [self defaultPrivateQueueContext];
[childContext performBlock:^{
//do stuff async
[childContext save:&error];
[self.defaultPrivateQueueContext performBlock:^{
[self.defaultPrivateQueueContext save:&error];
}];
}];
Upvotes: 0
Views: 651
Reputation: 21244
Saving the child will update the state of the objects in the child context and push the changes committed by the save to the parent. The parent will not persist these changes in the persistent store without a save in the parent context (assuming the parent is the root context).
You can see an illustration of this here.
Upvotes: 1