• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data application types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Core Data application types (From: "Mark Hill" <email@hidden>)
 >Re: Core Data application types (From: mmalc crawford <email@hidden>)
 >Re: Core Data application types (From: MH <email@hidden>)
 >Re: Core Data application types (From: Bill Dudney <email@hidden>)

  • Prev by Date: Re: Core Data application types
  • Next by Date: Re: Core Data application types
  • Previous by thread: Re: Core Data application types
  • Next by thread: Re: Core Data application types
  • Index(es):
    • Date
    • Thread