core-data icon indicating copy to clipboard operation
core-data copied to clipboard

NSPersistentContainer background context merge changes

Open arvindhsukumar opened this issue 7 years ago • 2 comments

NSPersistentContainer's newBackgroundContext() documentation states that the created context is setup to automatically consume didSave notifications. Yet, the syncContext in SyncContextOwner still merges changes manually on the main context's didSave.

Is it necessary?

arvindhsukumar avatar Apr 04 '18 07:04 arvindhsukumar

Good question. I noticed this in documentation as well.

evandelaney avatar Jun 10 '18 17:06 evandelaney

Suddenly came across this issue. By default contexts in NSPersistentContainer don't merge each other changes, although the documentations says the opposite (at leas about merging mainContext's changes into backgroundContext). Right now I'm trying to figure out why so.

So, answering your question: so far it seems like manual merging is necessary.

UPDATE: there is a flag to switch on the merge, so if it's switched there is no need for the manual merge context.automaticallyMergesChangesFromParent = true

DmIvanov avatar Jul 17 '18 21:07 DmIvanov