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


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 init(persistentStoreCoordinator:configurationName:at:options:). When you implement the initializer, you must ensure you load metadata during initialization and set it using metadata.

You must override these methods:


Working with State Information

var type: String

The type string of the receiver.

var persistentStoreCoordinator: NSPersistentStoreCoordinator?

The persistent store coordinator that loaded the receiver.

var configurationName: String

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

var options: [AnyHashable : Any]?

The options the store was initialized with.

var url: URL?

The URL for the receiver.

var identifier: String!

The unique identifier for the receiver.

var isReadOnly: Bool

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

Managing Metadata

class func metadataForPersistentStore(with: URL)

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

class func setMetadata([String : Any]?, forPersistentStoreAt: URL)

Sets the metadata for the store at a given URL.

var metadata: [String : Any]!

The metadata for the receiver.

func loadMetadata()

Instructs the receiver to load its metadata.

Setup and Teardown

func didAdd(to: NSPersistentStoreCoordinator)

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

func willRemove(from: NSPersistentStoreCoordinator?)

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

Supporting Migration

class func migrationManagerClass()

Returns the NSMigrationManager class for this store class.


Inherits From

Conforms To