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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access