Class

NSPersistentStore

The abstract base class for all Core Data persistent stores.

Declaration

@interface NSPersistentStore : NSObject

Overview

Core Data provides four store types—SQLite, Binary, XML, and In-Memory (the XML store is not available on iOS); these are described in Persistent Store Features. Core Data also provides subclasses of NSPersistentStore that you can use to define your own store types: NSAtomicStore and NSIncrementalStore. The Binary and XML stores are examples of atomic stores that inherit functionality from NSAtomicStore.

Subclassing Notes

You should not subclass NSPersistentStore directly. Core Data only supports subclassing of NSAtomicStore and NSIncrementalStore.

The designated initializer is initWithPersistentStoreCoordinator:configurationName:URL:options:. When you implement the initializer, you must ensure you load metadata during initialization and set it using metadata.

You must override these methods:

Topics

Initializing a Persistent Store

- initWithPersistentStoreCoordinator:configurationName:URL:options:

Returns a store initialized with the given arguments.

Working with State Information

type

The type string of the persistent store.

persistentStoreCoordinator

The persistent store coordinator that loaded the persistent store.

configurationName

The name of the managed object model configuration used to create the persistent store.

options

The options the store was initialized with.

URL

The URL for the persistent store.

identifier

The unique identifier for the persistent store.

readOnly

A Boolean value that indicates whether the persistent store is read-only.

Managing Metadata

+ metadataForPersistentStoreWithURL:error:

Returns the metadata from the persistent store at the given URL.

+ setMetadata:forPersistentStoreWithURL:error:

Sets the metadata for the store at a given URL.

metadata

The metadata for the persistent store.

- loadMetadata:

Instructs the persistent store to load its metadata.

Creating and Destroying a Persistent Store

- didAddToPersistentStoreCoordinator:

Invoked after the persistent store has been added to the persistent store coordinator.

- willRemoveFromPersistentStoreCoordinator:

Invoked before the persistent store is removed from the persistent store coordinator.

Supporting Migration

+ migrationManagerClass

Returns the migration manager class for this store class.

Supporting Core Spotlight

coreSpotlightExporter

The spotlight exporter associated with this persistent store.

Relationships

Inherits From

See Also

Creating Persistent Stores

NSPersistentStoreDescription

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

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.

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.

NSIncrementalStoreNode

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

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.