O'Reilly logo

Core Data in Swift by Marcus S. Zarra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parent/Child NSManagedObjectContext Design

In the previous section, you saw how to consume changes from one context into another. With iOS 5.0, Core Data added another option to handle change notifications. Instead of having every context talk directly to the NSPersistentStoreCoordinator, we can chain contexts together in a parent/child design.

Each child context will request objects from its parent context, and if that parent context doesn’t have the objects requested, it will pass that request up the chain until it hits the NSPersistentStoreCoordinator and I/O is performed. However, if the parent context does have a reference to the desired objects, then they’re returned to the child without I/O being performed.

Further, when a child makes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required