Instance Method


Configures the receiver’s persistent store coordinator with the appropriate stores for a given URL.


- (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url ofType:(NSString *)fileType modelConfiguration:(NSString *)configuration storeOptions:(NSDictionary<NSString *,id> *)storeOptions error:(NSError * _Nullable *)error;



An URL that specifies the location of the document's store.


The document type.


The name of the managed object model configuration to use. (The managed object model is associated with the persistent store coordinator.) Pass nil if you do not want to specify a configuration.


Options for the store. See “Store Options” in NSPersistentStoreCoordinator for possible values.


If the method does not complete successfully, upon return contains an NSError object that describes the problem.

Return Value

YES if the method completes successfully, otherwise NO.


This method is invoked automatically when an existing document is opened. You override this method to customize creation of a persistent store for a given document or store type. You can retrieve the persistent store coordinator with the following code:

[[self managedObjectContext] persistentStoreCoordinator];

You can override this method to create the store to save to or load from (invoked from within the other NSDocument methods to read/write files), which gives developers the ability to load/save from/to different persistent store types (default type is XML).

See Also

Managing the Persistence Objects


The managed object context for the document.


The managed object model of the document.

- persistentStoreTypeForFileType:

Returns the type of persistent store associated with the specified file type.