Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/CoreData.framework |
Availability | Available in iOS 3.0 and later. |
Declared in | NSPersistentStore.h |
Companion guides |
This class is the abstract base class for all Core Data persistent stores.
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 Stores. Core Data also provides a subclass of NSPersistentStore
, NSAtomicStore
. The Binary and XML stores are examples of atomic stores that inherit functionality from NSAtomicStore
.
You should not subclass NSPersistentStore
directly. Core Data currently only supports subclassing of NSAtomicStore
.
The designated initializer is initWithPersistentStoreCoordinator:configurationName:URL:options:
. When you implement the initializer, you must ensure you load metadata during initialization and set it using setMetadata:
.
You must override these methods:
– type
– persistentStoreCoordinator
– configurationName
– options
– URL
– setURL:
– identifier
– setIdentifier:
– isReadOnly
– setReadOnly:
+ metadataForPersistentStoreWithURL:error:
+ setMetadata:forPersistentStoreWithURL:error:
– metadata
– loadMetadata:
– setMetadata:
Returns the metadata from the persistent store at the given URL.
+ (NSDictionary *)metadataForPersistentStoreWithURL:(NSURL *)url error:(NSError **)error
The location of the store.
If an error occurs, upon return contains an NSError
object that describes the problem.
The metadata from the persistent store at url. Returns nil
if there is an error.
Subclasses must override this method.
NSPersistentStore.h
Returns the NSMigrationManager
class for this store class.
+ (Class)migrationManagerClass
The NSMigrationManager
class for this store class
In a subclass of NSPersistentStore
, you can override this to provide a custom migration manager subclass (for example, to take advantage of store-specific functionality to improve migration performance).
NSPersistentStore.h
Sets the metadata for the store at a given URL.
+ (BOOL)setMetadata:(NSDictionary *)metadata forPersistentStoreWithURL:(NSURL *)url error:(NSError **)error
The metadata for the store at url.
The location of the store.
If an error occurs, upon return contains an NSError
object that describes the problem.
YES
if the metadata was written correctly, otherwise NO
.
Subclasses must override this method to set metadata appropriately.
NSPersistentStore.h
Returns the name of the managed object model configuration used to create the receiver.
- (NSString *)configurationName
The name of the managed object model configuration used to create the receiver.
NSPersistentStore.h
Invoked after the receiver has been added to the persistent store coordinator.
- (void)didAddToPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator
The persistent store coordinator to which the receiver was added.
The default implementation does nothing. You can override this method in a subclass in order to perform any kind of setup necessary before the load method is invoked.
NSPersistentStore.h
Returns the unique identifier for the receiver.
- (NSString *)identifier
The unique identifier for the receiver.
The identifier is used as part of the managed object IDs for each object in the store.
NSPersistentStore
provides a default implementation to provide a globally unique identifier for the store instance.
NSPersistentStore.h
Returns a store initialized with the given arguments.
- (id)initWithPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)root configurationName:(NSString *)name URL:(NSURL *)url options:(NSDictionary *)options
A persistent store coordinator.
The name of the managed object model configuration to use. Pass nil
if you do not want to specify a configuration.
The URL of the store to load.
A dictionary containing configuration options.
A new store object, associated with coordinator, that represents a persistent store at url using the options in options and—if it is not nil
—the managed object model configuration configurationName.
You must ensure that you load metadata during initialization and set it using setMetadata:
.
This is the designated initializer for persistent stores.
NSPersistentStore.h
Returns a Boolean value that indicates whether the receiver is read-only.
- (BOOL)isReadOnly
YES
if the receiver is read-only, otherwise NO
.
NSPersistentStore.h
Instructs the receiver to load its metadata.
- (BOOL)loadMetadata:(NSError **)error
If an error occurs, upon return contains an NSError
object that describes the problem.
YES
if the metadata was loaded correctly, otherwise NO
.
There is no way to return an error if the store is invalid.
NSPersistentStore.h
Returns the metadata for the receiver.
- (NSDictionary *)metadata
The metadata for the receiver. The dictionary must include the store type (NSStoreTypeKey
) and UUID (NSStoreUUIDKey
).
Subclasses must override this method to provide storage and persistence for the store metadata.
NSPersistentStore.h
Returns the options with which the receiver was created.
- (NSDictionary *)options
The options with which the receiver was created.
See NSPersistentStoreCoordinator
for a list of key names for options in this dictionary.
NSPersistentStore.h
Returns the persistent store coordinator which loaded the receiver.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
The persistent store coordinator which loaded the receiver.
NSPersistentStore.h
Sets the unique identifier for the receiver.
- (void)setIdentifier:(NSString *)identifier
The unique identifier for the receiver.
NSPersistentStore.h
Sets the metadata for the receiver.
- (void)setMetadata:(NSDictionary *)storeMetadata
The metadata for the receiver.
NSPersistentStore.h
Sets whether the receiver is read-only.
- (void)setReadOnly:(BOOL)flag
YES
if the receiver is read-only, otherwise NO
.
NSPersistentStore.h
Sets the URL for the receiver.
- (void)setURL:(NSURL *)url
The URL for the receiver.
To alter the location of a store, send the persistent store coordinator a setURL:forPersistentStore:
message.
NSPersistentStore.h
Returns the type string of the receiver.
- (NSString *)type
The type string of the receiver.
This string is used when specifying the type of store to add to a persistent store coordinator.
Subclasses must override this method to provide a unique type.
NSPersistentStore.h
Returns the URL for the receiver.
- (NSURL *)URL
The URL for the receiver.
NSPersistentStore.h
Invoked before the receiver is removed from the persistent store coordinator.
- (void)willRemoveFromPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator
The persistent store coordinator from which the receiver was removed.
The default implementation does nothing. You can override this method in a subclass in order to perform any clean-up before the store is removed from the coordinator (and deallocated).
NSPersistentStore.h
Last updated: 2009-05-01