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

class NSPersistentContainer

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

Object Modeling

class NSManagedObjectModel

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

class NSEntityDescription

A description of an entity in Core Data.

class NSPropertyDescription

A description of a property of a Core Data entity.

class NSAttributeDescription

A description of an attribute of a Core Data entity.

class NSDerivedAttributeDescription

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

class NSRelationshipDescription

A description of a relationship of a Core Data entity.

Object Management

class NSManagedObjectContext

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

class NSManagedObject

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

class NSManagedObjectID

A compact, universal identifier for a managed object.

Store Coordination

class NSPersistentStoreCoordinator

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

class NSPersistentStore

The abstract base class for all Core Data persistent stores.

class NSPersistentStoreDescription

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

class NSPersistentStoreRequest

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

class NSPersistentStoreResult

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

class NSPersistentStoreAsynchronousResult

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

class 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.

class NSAtomicStore

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

class NSAtomicStoreCacheNode

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

class NSIncrementalStore

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

class 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.