Updated core data concurrency documentation? Updated core data concurrency documentation? ios ios

Updated core data concurrency documentation?


The best discussion is now under 'Concurrency' within the NSManagedObjectContext documentation.

My summary:

Thread confinement is still required. The big changes introduced by iOS 5/OS X v10.7 were that contexts can now have other contexts as parents and can manage their own serial queues.

Changes are automatically migrated from children to parent upon a save. That's now what save means. Only if your parent is the persistent store are you actually committing to disk.

So all that stuff about synchronising by notifications is what Apple doesn't want you to follow. All of those mechanisms are still available but Apple has pulled the most common patterns directly into the framework.


The Core Data Programming Guide has been updated for iOS 9/OS X El Capitan. See https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Conceptual/CoreData/Concurrency.html.

I also found WWDC 2014 session 225 What's new in Core Data (at 22:50) very helpful in understanding both current and historic concurrency methods.


Thread confinement has been obsoleted. You can see this in the header for NSManagedObjectContext:

NSConfinementConcurrencyType        = 0x00,    /* this option is obsolete and not recommended for new code. */

When a context is created with -init, it calls the initializer -initWithConcurrencyType: with the argument NSConfinementConcurrencyType. This is the threading model described in the Core Data Programming Guide section on concurrency, that has been obsolete and not recommended for some time. In the words of one Core Data engineer "It just didn't work.".

Unfortunately that Core Data Programming Guide has not been updated to describe the current recommended best practices for concurrency and other advancements.But hey, at least it's not telling you to use locking!

The Incremental Store Programming Guide has been updated recently. It describes how to implement an NSIncrementalStore, and in doing so does a very good job of explaining some of Core Data's internals. For example, it describes what a fault is and how faults are fired far better than the Core Data programming guide ever did. The Core Data release notes for the past several years have included some updated information about best practices, and there are several tech notes that are relevant to Core Data.

The best information in the last several years has been the yearly "What's New In Core Data" sessions at WWDC. For concurrency, you should check out these WWDC sessions:

WWDC 2011 What's new in Core Data on MacOS X. The MacOS X session was a little more detailed than the iOS session.

and

WWDC 2012 Core Data Best Practices

I would encourage you to use the "Feedback" button on the Core Data Programming Guide pages, or file a radar bug asking for the documentation to be updated.