Updating Items

With the persistent container set up, you can now interact with Core Data. Primarily, you will do this through its viewContext. This is how you will both create new entities and save changes.

The viewContext is an instance of NSManagedObjectContext. This is the portal through which you interact with your entities. You can think of the managed object context as an intelligent scratch pad. When you ask the context to fetch some entities, the context will work with its persistent store coordinator to bring temporary copies of the entities and object graph into memory. Unless you ask the context to save its changes, the persisted data remains the same.

Inserting into the context

When an entity is created, it should ...

Get iOS Programming: The Big Nerd Ranch Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.