| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in Mac OS X v10.5 and later. |
| Declared in | NSPersistentStore.h |
| Companion guides | |
| Related sample code |
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 iPhone OS); 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.hReturns 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.hSets 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.hReturns 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.hInvoked 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.hReturns 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.hReturns 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.hReturns a Boolean value that indicates whether the receiver is read-only.
- (BOOL)isReadOnly
YES if the receiver is read-only, otherwise NO.
NSPersistentStore.hInstructs 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.hReturns 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.hReturns 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.hReturns the persistent store coordinator which loaded the receiver.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
The persistent store coordinator which loaded the receiver.
NSPersistentStore.hSets the unique identifier for the receiver.
- (void)setIdentifier:(NSString *)identifier
The unique identifier for the receiver.
NSPersistentStore.hSets the metadata for the receiver.
- (void)setMetadata:(NSDictionary *)storeMetadata
The metadata for the receiver.
NSPersistentStore.hSets whether the receiver is read-only.
- (void)setReadOnly:(BOOL)flag
YES if the receiver is read-only, otherwise NO.
NSPersistentStore.hSets 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.hReturns 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.hReturns the URL for the receiver.
- (NSURL *)URL
The URL for the receiver.
NSPersistentStore.hInvoked 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© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-05-01)