iOS Reference Library Apple Developer
Search

Registering a Custom Store Type

To use a custom store type in an application, you must register the store type with the NSPersistentStoreCoordinator class using registerStoreClass:forStoreType:. The type name must be a unique string.

Typically you define the store type as a string constant:

// in MyAtomicStore.h
extern NSString *MY_ATOMIC_STORE_TYPE;
 
// in MyAtomicStore.m
NSString *MY_ATOMIC_STORE_TYPE = @"MyAtomicStore";

You should ensure that a type is registered before you try to add a store of that type to a persistent store coordinator. For example, in an application delegate you might register in applicationWillFinishLaunching:.

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
    [NSPersistentStoreCoordinator registerStoreClass:[MyAtomicStore class]
                                     forStoreType:MY_ATOMIC_STORE_TYPE];
}

In a document-based application, the type is the identifier NSPersistentDocument uses to associate a persistent store type with a document type (see persistentStoreTypeForFileType:).




Last updated: 2009-03-07

Did this document help you? Yes It's good, but... Not helpful...