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 a managed object model, a managed object context, and a persistent store coordinator that connects to your app's stores.

You use an NSPersistentContainer to set up the model, context, and store coordinator all at once.

Topics

Stack Fundamentals

class NSPersistentContainer

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

class NSManagedObjectModel

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

class NSManagedObjectContext

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

class NSPersistentStoreCoordinator

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

See Also

First Steps

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.