• 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
Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Where to properly call [NSPersistentStoreCoordinator persistentStores] ?


  • Subject: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
  • From: Serg Koren <email@hidden>
  • Date: Fri, 18 Aug 2006 16:14:38 -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 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
}


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


  • Follow-Ups:
    • Re: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: [self init] vs. [super init] in initWithCoder
  • Next by Date: Re: What's the fastest way to get icons for file/folders?
  • Previous by thread: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
  • Next by thread: Re: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
  • Index(es):
    • Date
    • Thread