Core Data Stack

Manage and persist your app’s model layer.

Overview

Core Data provides a set of classes that collaboratively support your app’s model layer:

Diagram showing that a persistent container instance contains references to a managed object model, a managed object context, and a persistent store coordinator that connects to your app's stores.

You use an NSPersistentContainer instance to set up the model, context, and store coordinator simultaneously.

Topics

Stack Setup

NSPersistentContainer

A container that encapsulates the Core Data stack in your app.

Object Modeling

NSManagedObjectModel

A programmatic representation of the .xcdatamodeld file describing your objects.

NSEntityDescription

A description of an entity in Core Data.

NSPropertyDescription

A description of a property of a Core Data entity.

NSAttributeDescription

A description of an attribute of a Core Data entity.

NSDerivedAttributeDescription

A description of an attribute of a Core Data entity that derives its value from one or more other properties.

NSRelationshipDescription

A description of a relationship of a Core Data entity.

Object Management

NSManagedObjectContext

An object space that you use to manipulate and track changes to managed objects.

NSManagedObject

A base class that implements the behavior required of a Core Data model object.

NSManagedObjectID

A compact, universal identifier for a managed object.

Store Coordination

NSPersistentStoreCoordinator

A coordinator that uses the model to help contexts and persistent stores communicate.

NSPersistentStore

The abstract base class for all Core Data persistent stores.

NSPersistentStoreDescription

A description object used to create and load a persistent store.

NSPersistentStoreRequest

Criteria used to retrieve data from or save data to a persistent store.

NSPersistentStoreResult

The abstract base class for results returned from a persistent store coordinator.

NSPersistentStoreAsynchronousResult

A concrete class used to represent the results of an asynchronous request.

NSSaveChangesRequest

An encapsulation of a collection of changes to be made by an object store in response to a save operation on a managed object context.

NSAtomicStore

An abstract superclass that you subclass to create a Core Data atomic store.

NSAtomicStoreCacheNode

A concrete class that you use to represent basic nodes in a Core Data atomic store.

NSIncrementalStore

An abstract superclass defining the API through which Core Data communicates with a store.

NSIncrementalStoreNode

A concrete class used to represent basic nodes in a Core Data incremental store.

See Also

Essentials

Creating a Core Data Model

Create a data model file to contain your app’s object structure.

Setting Up a Core Data Stack

Set up the classes that manage and persist your app’s objects.