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

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


  • Follow-Ups:
    • Re: Where to properly call [NSPersistentStoreCoordinator persistentStores] ?
      • From: Serg Koren <email@hidden>
References: 
 >Where to properly call [NSPersistentStoreCoordinator persistentStores] ? (From: Serg Koren <email@hidden>)

  • Prev by Date: Re: Re: [self init] vs. [super init] in initWithCoder
  • Next by Date: Re: 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