Instance Method


Adds a new persistent store of a specified type at a given location, and returns the new store.


- (__kindof NSPersistentStore *)addPersistentStoreWithType:(NSString *)storeType configuration:(NSString *)configuration URL:(NSURL *)storeURL options:(NSDictionary *)options error:(NSError * _Nullable *)error;



A string constant (such as NSSQLiteStoreType) that specifies the store type—see Persistent Store Types for possible values.


The name of a configuration in the receiver's managed object model that will be used by the new store. The configuration can be nil, in which case no other configurations are allowed.


The file location of the persistent store.


A dictionary containing key-value pairs that specify whether the store should be read-only, and whether (for an XML store) the XML file should be validated against the DTD before it is read. For key definitions, see Store Options and Migration Options. This value may be nil.


If a new store cannot be created, upon return contains an instance of NSError that describes the problem

Return Value

The newly-created store or, if an error occurs, nil.


See Also

Configuring Persistent Stores

- addPersistentStoreWithDescription:completionHandler:

Adds a new persistent store of a specified description, and returns the new store.

- setURL:forPersistentStore:

Sets the URL for a given persistent store.

- removePersistentStore:error:

Removes a given persistent store.

- destroyPersistentStoreAtURL:withType:options:error:

Deletes (or truncates) the target persistent store in accordance with the store class' requirements.

- migratePersistentStore:toURL:options:withType:error:

Moves a persistent store to a new location, changing the storage type if necessary.


The persistent stores associated with the coordinator.

- persistentStoreForURL:

Returns the persistent store for the specified URL.

- URLForPersistentStore:

Returns the URL for a given persistent store.


Name of the coordinator.

Store Options

Use options dictionary keys to specify store behavior and characteristics.