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

Adding the NSManagedObjectContext

Next to NSManagedObject, NSManagedObjectContext is the object in the Core Data stack that we’ll most often access. The NSManagedObjectContext is the object we access when we want to save to disk, when we want to read data into memory, and when we want to create new objects. The NSManagedObjectContext is at the top of the Core Data stack in that it’s accessed directly by our code frequently. It’s much less common for us to need to go deeper into the stack.

NSManagedObjectContext can’t be accessed from multiple threads. Each thread that needs access to data should have its own NSManagedObjectContext. This is generally not an issue, since it’s very easy to create multiple contexts as needed for data that has to ...

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