<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSAtomicStore",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAtomicStore"
  },
  "title" : "NSAtomicStore"
}
-->

# NSAtomicStore

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

```
class NSAtomicStore
```

## Overview

Use an atomic store to handle data sets that can be expressed in memory. The atomic store API favors simplicity over performance.

This class provides default implementations of some utility methods. Create a custom atomic store subclass when you have a custom file format that you want to integrate with a Core Data app. When you create a subclass, override the following [`NSAtomicStore`](/documentation/CoreData/NSAtomicStore) methods:

- [`load()`](/documentation/CoreData/NSAtomicStore/load())
- [`newCacheNode(for:)`](/documentation/CoreData/NSAtomicStore/newCacheNode(for:))
- [`newReferenceObject(for:)`](/documentation/CoreData/NSAtomicStore/newReferenceObject(for:))
- [`save()`](/documentation/CoreData/NSAtomicStore/save())
- [`updateCacheNode(_:from:)`](/documentation/CoreData/NSAtomicStore/updateCacheNode(_:from:))

Also override the following properties and methods of [`NSPersistentStore`](/documentation/CoreData/NSPersistentStore), from which the atomic store class inherits:

- [`type`](/documentation/CoreData/NSPersistentStore/type)
- [`identifier`](/documentation/CoreData/NSPersistentStore/identifier)
- [`metadata`](/documentation/CoreData/NSPersistentStore/metadata)
- [`metadataForPersistentStore(with:)`](/documentation/CoreData/NSPersistentStore/metadataForPersistentStore(with:))
- [`setMetadata(_:forPersistentStoreAt:)`](/documentation/CoreData/NSPersistentStore/setMetadata(_:forPersistentStoreAt:))

`NSAtomicStore` provides a default dictionary of metadata. This dictionary contains the store type and identifier ([`NSStoreTypeKey`](/documentation/CoreData/NSStoreTypeKey) and [`NSStoreUUIDKey`](/documentation/CoreData/NSStoreUUIDKey)) as well as store versioning information. Subclasses must ensure that the metadata is saved along with the store data.

## Topics

### Initializing a Store

[`-  initWithPersistentStoreCoordinator:configurationName:URL:options:`](/documentation/CoreData/NSAtomicStore/init(persistentStoreCoordinator:configurationName:at:options:))

Creates an atomic store at the specified location.

### Loading a Store

[`-  load:`](/documentation/CoreData/NSAtomicStore/load())

Loads the cache nodes for the receiver.

[`-  objectIDForEntity:referenceObject:`](/documentation/CoreData/NSAtomicStore/objectID(for:withReferenceObject:))

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

[`-  addCacheNodes:`](/documentation/CoreData/NSAtomicStore/addCacheNodes(_:))

Registers a set of cache nodes with the receiver.

### Updating Cache Nodes

[`-  newCacheNodeForManagedObject:`](/documentation/CoreData/NSAtomicStore/newCacheNode(for:))

Returns a new cache node for a given managed object.

[`-  newReferenceObjectForManagedObject:`](/documentation/CoreData/NSAtomicStore/newReferenceObject(for:))

Returns a new reference object for a given managed object.

[`-  updateCacheNode:fromManagedObject:`](/documentation/CoreData/NSAtomicStore/updateCacheNode(_:from:))

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

[`-  willRemoveCacheNodes:`](/documentation/CoreData/NSAtomicStore/willRemoveCacheNodes(_:))

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

### Saving a Store

[`-  save:`](/documentation/CoreData/NSAtomicStore/save())

Saves the cache nodes.

### Utility Methods

[`-  cacheNodes`](/documentation/CoreData/NSAtomicStore/cacheNodes())

Returns the set of cache nodes registered with the receiver.

[`-  cacheNodeForObjectID:`](/documentation/CoreData/NSAtomicStore/cacheNode(for:))

Returns the cache node for a given managed object ID.

[`-  referenceObjectForObjectID:`](/documentation/CoreData/NSAtomicStore/referenceObject(for:))

Returns the reference object for a given managed object ID.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSPersistentStore`](/documentation/CoreData/NSPersistentStore)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)