<!--
{
  "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/NSPersistentStore",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPersistentStore"
  },
  "title" : "NSPersistentStore"
}
-->

# NSPersistentStore

The abstract base class for all Core Data persistent stores.

```
class NSPersistentStore
```

## 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`](/documentation/CoreData/NSAtomicStore) and [`NSIncrementalStore`](/documentation/CoreData/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`](/documentation/CoreData/NSAtomicStore) and [`NSIncrementalStore`](/documentation/CoreData/NSIncrementalStore).

The designated initializer is [`init(persistentStoreCoordinator:configurationName:at:options:)`](/documentation/CoreData/NSPersistentStore/init(persistentStoreCoordinator:configurationName:at:options:)). When you implement the initializer, you must ensure you load metadata during initialization and set it using [`metadata`](/documentation/CoreData/NSPersistentStore/metadata).

You must override these methods:

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

## Topics

### Creating a Persistent Store

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

Returns a store initialized with the given arguments.

### Getting Store Configuration

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

The name of the managed object model configuration that creates the persistent store.

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

The options that Core Data uses to create the store.

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

The persistent store coordinator that loads the persistent store.

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

The type string of the persistent store.

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

The types of persistent stores that Core Data supports.

[Persistent Store Types](/documentation/CoreData/persistent-store-types)

Persist data through the available store types.

### Managing Store Attributes

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

The unique identifier for the persistent store.

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

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

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

The URL for the persistent store.

### Managing Store Metadata

[`+  metadataForPersistentStoreWithURL:error:`](/documentation/CoreData/NSPersistentStore/metadataForPersistentStore(with:))

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

[`+  setMetadata:forPersistentStoreWithURL:error:`](/documentation/CoreData/NSPersistentStore/setMetadata(_:forPersistentStoreAt:))

Sets the metadata for the store at a given URL.

[`-  loadMetadata:`](/documentation/CoreData/NSPersistentStore/loadMetadata())

Instructs the persistent store to load its metadata.

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

The metadata for the persistent store.

### Responding to the Store Life Cycle

[`-  didAddToPersistentStoreCoordinator:`](/documentation/CoreData/NSPersistentStore/didAdd(to:))

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

[`-  willRemoveFromPersistentStoreCoordinator:`](/documentation/CoreData/NSPersistentStore/willRemove(from:))

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

### Integrating with Spotlight

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

The spotlight exporter associated with this persistent store.

### Providing a Migration Manager

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

Returns the migration manager class for this store class.

### Notifications

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

## Relationships

### Conforms To

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

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

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

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

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

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

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Inherited By

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

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

---

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)