Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

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:).



< Previous PageNext Page > Hide TOC


Last updated: 2008-02-08




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice