Concurrent Core Data, Now Easier Than Ever
Our main thread-bounded operations use
viewContext. Background work can be performed on a context returned by the factory methodnewBackgroundContext(). However, usage ofperformBackgroundTask(_:)is recommended because of the under-the-hood optimizations.All contexts are independent of each other, there are no parent/child relationships here. To receive changes from other contexts we simply set
automaticallyMergesChangesFromParentflag totrueon a context. Despite its name (*FromParent*), it works correctly with theNSPersistentContainersetup in which contexts are siblings:
Not sure I understand that last bit.
Update (2016-07-07): James O’Leary says that, despite the name of the property, it treats the persistent store itself as an implicit parent context.
Comments
Stay up-to-date by subscribing to the Comments RSS Feed for this post.