Framework

Core Data

Create generalized and automated solutions to common tasks associated with object life-cycle and object graph management, including persistence.

Overview

This collection of documents provides the API reference for the Core Data framework. Core Data provides object graph management and persistence for Foundation and Cocoa applications. For more details, see Core Data Basics

Symbols

Classes

NSAsynchronousFetchRequestNSAsynchronousFetchResult
NSAtomicStore

NSAtomicStore is an abstract superclass that you can subclass to create a Core Data atomic store. It provides default implementations of some utility methods. You use a custom atomic store if you have a custom file format that you want to integrate with a Core Data application.

NSAtomicStoreCacheNode

NSAtomicStoreCacheNode is a concrete class to represent basic nodes in a Core Data atomic store.

NSAttributeDescription

The NSAttributeDescription class is used to describe attributes of an entity described by an instance of NSEntityDescription.

NSBatchDeleteRequestNSBatchDeleteResultNSBatchUpdateRequestNSBatchUpdateResultNSConstraintConflict
NSEntityDescription

An NSEntityDescription object describes an entity in Core Data. Entities are to managed objects what Class is to id, or—to use a database analogy—what tables are to rows. An instance specifies an entity’s name, its properties (its attributes and relationships, expressed by instances of NSAttributeDescription and NSRelationshipDescription) and the class by which it is represented.

NSEntityMapping

Instances of NSEntityMapping specify how to map an entity from a source to a destination managed object model.

NSEntityMigrationPolicy

Instances of NSEntityMigrationPolicy customize the migration process for an entity mapping.

NSExpressionDescription

Instances of NSExpressionDescription objects represent a special property description type intended for use with the NSFetchRequest propertiesToFetch method.

NSFetchedPropertyDescription

The NSFetchedPropertyDescription class is used to define “fetched properties.” Fetched properties allow you to specify related objects through a weak, unidirectional relationship defined by a fetch request.

NSFetchedResultsController

You use a fetched results controller to efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object.

NSFetchRequest

An instance of NSFetchRequest describes search criteria used to retrieve data from a Persistent store.

NSFetchRequestExpression

Instances of NSFetchRequestExpression represent expressions which evaluate to the result of executing a fetch request on a managed object context.

NSIncrementalStore

NSIncrementalStore is an abstract superclass defining the API through which Core Data communicates with a store. This interface is designed to allow you to create persistent stores which load and save data incrementally, allowing for the management of large and/or shared datasets. See Incremental Store Programming Guide for an implementation strategy and best practices when implementing your own incremental store.

NSIncrementalStoreNode

NSIncrementalStoreNode is a concrete class to represent basic nodes in a Core Data incremental store.

NSManagedObject

NSManagedObject is a generic class that implements all the basic behavior required of a Core Data model object. It is not possible to use instances of direct subclasses of NSObject (or any other class not inheriting from NSManagedObject) with a managed object context. You may create custom subclasses of NSManagedObject, although this is not always required. If no custom logic is needed, a complete Object graph can be formed with NSManagedObject instances.

NSManagedObjectContext

An instance of NSManagedObjectContext represents a single “object space” or scratch pad in an application. Its primary responsibility is to manage a collection of managed objects. These objects form a group of related model objects that represent an internally consistent view of one or more persistent stores. A single managed object instance exists in one and only one context, but multiple copies of an object can exist in different contexts. Thus object uniquing is scoped to a particular context.

NSManagedObjectID

An NSManagedObjectID object is a compact, universal identifier for a managed object. This forms the basis for uniquing in the Core Data Framework. A managed object ID uniquely identifies the same managed object both between managed object contexts in a single application, and in multiple applications (as in distributed systems). Identifiers contain the information needed to exactly describe an object in a persistent store (like the primary key in the database), although the detailed information is not exposed. The framework completely encapsulates the “external” information and presents a clean object oriented interface.

NSManagedObjectModel

An NSManagedObjectModel object describes a schema—a collection of entities (data models) that you use in your application.

NSMappingModel

Instances of NSMappingModel specify how to map from a source to a destination managed object model.

NSMergeConflict

A merge conflict encapsulates conflicts that occur when attempting to save changes in a managed object context.

NSMergePolicy

You use a merge policy object to resolve conflicts between the persistent store and in-memory versions of managed objects.

NSMigrationManager

Instances of NSMigrationManager perform a migration of data from one persistent store to another using a given mapping model.

NSPersistentContainer

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

NSPersistentStore

This class is the abstract base class for all Core Data persistent stores.

NSPersistentStoreAsynchronousResult
NSPersistentStoreCoordinator

Instances of NSPersistentStoreCoordinator associate persistent stores (by type) with a model (or more accurately, a configuration of a model) and serve to mediate between the persistent store or stores and the managed object context or contexts. Instances of NSManagedObjectContext use a coordinator to save object graphs to persistent storage and to retrieve model information. A context without a coordinator is not fully functional as it cannot access a model except through a coordinator. The coordinator is designed to present a façade to the managed object contexts such that a group of persistent stores appears as an aggregate store. A managed object context can then create an object graph based on the union of all the data stores the coordinator covers.

NSPersistentStoreDescription

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

NSPersistentStoreRequest

An instance of NSPersistentStoreRequest describes criteria used to retrieve data from or save data to Persistent store.

NSPersistentStoreResult
NSPropertyDescription

The NSPropertyDescription class is used to define properties of an entity in a Core Data managed object model. Properties are to entities what instance variables are to classes.

NSPropertyMapping

Instances of NSPropertyMapping specify in a mapping model how to map from a property in a source entity to a property in a destination entity.

NSQueryGenerationToken
NSRelationshipDescription

The NSRelationshipDescription class is used to describe relationships of an entity in an NSEntityDescription object.

NSSaveChangesRequest

A save changes request encapsulates a collection of changes to be made by an object store in response to a save operation on a managed object context.

Protocols

NSFetchedResultsControllerDelegate

An instance of NSFetchedResultsController uses methods in this protocol to notify its delegate that the controller’s fetch results have been changed due to an add, remove, move, or update operations.

NSFetchedResultsSectionInfo

This protocol defines the interface for section objects vended by an instance of NSFetchedResultsController.

NSFetchRequestResult

Reference

Core Data Constants

This document describes the constants defined in the Core Data framework and not described in a document for an individual class.

Core Data EnumerationsCore Data Data Types

Structures

NSFetchRequestResultType

These constants specify the possible result types a fetch request can return.

NSSnapshotEventType

Constants returned from awake(fromSnapshotEvents:) to denote the reason why a managed object may need to reinitialize values.

Extended Types

CocoaError

Describes errors within the Cocoa error domain.

Code

The error code itself.

Name