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


class NSAtomicStore : NSPersistentStore


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

The atomic stores are all intended to handle data sets that can be expressed in memory. The atomic store API favors simplicity over performance.

Subclassing Notes

Methods to Override

In a subclass of NSAtomicStore, you must override the following methods to provide behavior appropriate for your store:

These are in addition to the methods you must override for a subclass of NSPersistentStore:


Loading a Store

func load()

Loads the cache nodes for the receiver.

func objectID(for: NSEntityDescription, withReferenceObject: Any) -> NSManagedObjectID

Returns a managed object ID from the reference data for a specified entity.

func addCacheNodes(Set<NSAtomicStoreCacheNode>)

Registers a set of cache nodes with the receiver.

Updating Cache Nodes

func newCacheNode(for: NSManagedObject) -> NSAtomicStoreCacheNode

Returns a new cache node for a given managed object.

func newReferenceObject(for: NSManagedObject) -> Any

Returns a new reference object for a given managed object.

func updateCacheNode(NSAtomicStoreCacheNode, from: NSManagedObject)

Updates the given cache node using the values in a given managed object.

func willRemoveCacheNodes(Set<NSAtomicStoreCacheNode>)

Method invoked before the store removes the given collection of cache nodes.

Saving a Store

func save()

Saves the cache nodes.

Utility Methods

func cacheNodes() -> Set<NSAtomicStoreCacheNode>

Returns the set of cache nodes registered with the receiver.

func cacheNode(for: NSManagedObjectID) -> NSAtomicStoreCacheNode?

Returns the cache node for a given managed object ID.

func referenceObject(for: NSManagedObjectID) -> Any

Returns the reference object for a given managed object ID.


Inherits From

Conforms To

See Also

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