On Dec 23, 2008, at 4:44 PM, Jerry Krinock wrote:

The NSPersistentDocument documentation doesn't give much detail -- "... an NSPersistenDocument creates its own ready-to-use persistence stack". I presume that it uses -mergedModelFromBundles:?

<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPersistentDocument_Class/Reference/Reference.html#//apple_ref/doc/uid/TP30001179-CJBJBIHA >

managedObjectModel
Returns the receiver’s managed object model.

- (id)managedObjectModel

Return Value
The receiver’s managed object model, used to configure the receiver’s persistent store coordinator.

Discussion
By default the Core Data framework creates a merged model from all models in the application bundle ([NSBundle mainBundle]). You can override this method to return a specific model to use to create persistent stores. A typical implementation might include code similar to the following fragment:

NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:@"MyModel" ofType:@"mom"];
NSURL *url = [NSURL fileURLWithPath:path];
NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:url]; Normally you would cache the model as an instance variable. If all your document instances use the same model, however, you can increase the efficiency of this method by caching a single instance, as illustrated in the following example.

- (id)managedObjectModel {
static id sharedModel = nil;
if (sharedModel == nil) {
sharedModel = [[super managedObjectModel] retain];
}
return sharedModel;
}
Special Considerations
In applications built on Mac OS X v10.4, by default the Core Data framework creates a merged model from all the models found in the application bundle and the frameworks against which the application is linked.

Availability
        • Available in Mac OS X v10.4 and later.


mmalc

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to