Wednesday, September 23, 2015

The Big Nerd Ranch Core Data Stack

Robert Edwards notes that the Nested Managed Object Context Pattern has some cons:

  • Slower than Shared Persistent Store Coordinator Pattern when inserting large data sets
  • awakeFromInsert being called on NSManagedObject subclasses for each context in the parent chain
  • Merge policies only apply to a context saving to a store and not to its parent context


Since saving an NSManagedObjectContext will only propagate changes up a single level to the parentContext, the Big Nerd Ranch Core Data Stack listens for save notifications and ensures that the changes get persisted all the way up the chain to your store.

You may sometimes need to perform large import operations where the nested context performance would be the bottleneck. For that, we’ve included a function to vend you a managed object context with its own stack newBatchOperationContext(setupCallback: CoreDataStackBatchMOCCallback). This follows the pattern outlined in Shared Store Stack Pattern.

Comments RSS · Twitter

Leave a Comment