Instance Method


Returns an atomic store, initialized with the given arguments.


- (instancetype)initWithPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator configurationName:(NSString *)configurationName URL:(NSURL *)url options:(NSDictionary *)options;



A persistent store coordinator.


The name of the managed object model configuration to use.


The URL of the store to load. This value must not be nil.


A dictionary containing configuration options.

Return Value

An atomic store, initialized with the given arguments, or nil if the store could not be initialized.


You typically do not invoke this method yourself; it is invoked by the persistent store coordinator during addPersistentStoreWithType:configuration:URL:options:error:, both when a new store is created and when an existing store is opened.

In your implementation, you should check whether a file already exists at url; if it does not, then you should either create a file here or ensure that your load: method does not fail if the file does not exist.

Any subclass of NSAtomicStore must be able to handle being initialized with a URL pointing to a zero-length file. This serves as an indicator that a new store is to be constructed at the specified location and allows you to securely create reservation files in known locations which can then be passed to Core Data to construct stores. You may choose to create zero-length reservation files during initWithPersistentStoreCoordinator:configurationName:URL:options: or load:. If you do so, you must remove the reservation file if the store is removed from the coordinator before it is saved.

You should ensure that you load metadata during initialization and set it using setMetadata:.

Special Considerations

You must invoke super’s implementation to ensure that the store is correctly initialized.

See Also