Re: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
Re: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
- Subject: Re: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
- From: Chris Hanson <email@hidden>
- Date: Fri, 18 Aug 2006 14:29:39 -0700
On Aug 18, 2006, at 1:14 PM, Serg Koren wrote:
I'm trying to get an array of persistenStores from my CoreData
Document app. I'm loading my model and trying to get the store
for the model I just loaded PRIOR to any user interaction with the
window.
What are you really trying to accomplish by doing this? That is,
what end goal will addressing this help you achieve? There may be a
better way to go about doing it. In general, a persistent document's
persistent store coordinator won't have any persistent stores until
it's saved, and then it will be associated with a single persistent
store. An opened document will be associated with a single
persistent store.
Code snippet I'm using follows from the NSPersistentDocument
subclass called from init:
-(void) getCoreDataEnvironment
{
myContext = [self managedObjectContext];
myCoordinator = [myContext persistentStoreCoordinator];
myManagedObjectModel = [myCoordinator managedObjectModel];
myEntities = [myManagedObjectModel
entitiesByName]; // works...returns 6
myPersistentStores = [myCoordinator
persistentStores]; // returns 0
}
It looks like this method just caches these values in instance
variables. Why do this, when they're already accessible to your
document code anywhere it needs them via the above methods?
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden