Re: Core Data application types
Re: Core Data application types
- Subject: Re: Core Data application types
- From: mmalc crawford <email@hidden>
- Date: Fri, 18 May 2007 11:08:15 -0700
On May 18, 2007, at 10:42 AM, Bill Dudney wrote:
You should be able to have as many managed object models as necessary.
something like this;
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel != nil) {
return managedObjectModel;
}
managedObjectModel = [[NSManagedObjectModel
mergedModelFromBundles:nil] retain];
return managedObjectModel;
}
[...]
NSPersistentStore *libStore = [[self persistentStoreCoordinator]
addPersistentStoreWithType:NSSQLiteStoreType configuration:nil
URL:libURL options:nil error:&error];
This creates a single merged model. If the goal is literally to have
"2 stores of different types within 1 application" then as a
generalisation this won't work.
If you really want two stores that contain different entities, then
either:
1. You need a separate managed object model for both.
If the models are different, then you also need a separate persistent
store coordinator for each.
2. You define configurations for each model, combine them (as above)
and create the coordinator. When you add a persistent store
(addPersistentStoreWithType:configuration:URL:options:error:), you do
so with the appropriate configuration.
As an aside, note that in any case you cannot create relationships
between objects in different stores.
NSPersistentStore *libStore = [[self persistentStoreCoordinator]
addPersistentStoreWithType:NSSQLiteStoreType configuration:nil
URL:libURL options:nil error:&error];
NSPersistentStore is not a public class...
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden