Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
- Subject: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
- From: Serg Koren <email@hidden>
- Date: Mon, 14 Aug 2006 11:24:27 -0400
Hi,
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.
Where should I be calling this? In a subclass of my NSWindow in
didLoad or somewhere more appropriately in my NSPersistentDocument
subclass--and if so where?
If I do it in my document class windowControllerDidLoadNib it gets
invoked but I'm getting 0 stores returned, so I'm assuming I'm calling
it too early in the event cycle so although the window itself is
loaded, the store isn't associated with the document yet. If I call
it from a button action (which I don't want to do) on the same window
I get the store properly so it seems like an event timing issue.
I'm just getting started with Cocoa/CoreData. Is there a doc that
gives a nice overview of the CoreData event life cycle as it ties in
with NSWindow, etc?
Code snippet I'm using follows from the NSPersistentDocument subclass:
-(void) getCoreDataEnvironment
{
myContext = [self managedObjectContext];
myCoordinator = [myContext persistentStoreCoordinator];
myManagedObjectModel = [myCoordinator managedObjectModel];
myEntities = [myManagedObjectModel
entitiesByName]; // works...returns 6
myPersistentStores = [myCoordinator
persistentStores]; // returns 0
}
This appears to be correct, just being called in the wrong spot.
Where should I be calling this on window load prior to user interaction?
Thanks,
S
_______________________________________________
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