• 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: Default Instance of entity in Core Data Document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Default Instance of entity in Core Data Document


  • Subject: Re: Default Instance of entity in Core Data Document
  • From: mmalc crawford <email@hidden>
  • Date: Tue, 31 Jul 2007 11:08:11 -0700


On Jul 31, 2007, at 10:57 AM, Adam Knight wrote:

First, I need to check for an instance of the entity once my managedObjectContext is finished loading, and add one if it's missing. Where is the right place to do this? awakeFromNib seems to be too early (the objects aren't loaded yet), and I can't do the usual trick of adding an observer to the object controller's "content" key, since it won't ever fire if the file contains no instances of the entity.
Use windowControllerDidLoadNib in NSDocument for that. I use this myself to check to see if fileURL is set and if not then I insert a blank entity for editing so the document is useful from the start.

Assuming the common pattern where you want to create an instance of an object when the document is first created and never delete it thereafter, you should use initWithType:error: instead -- see:

<http://developer.apple.com/documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/04_Department/chapter_5_section_2.html >

If you subsequently need to do other store-related setup, you should almost certainly use configurePersistentStoreCoordinatorForURL:ofType:error:.

mmalc

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >Default Instance of entity in Core Data Document (From: Frank Schmitt <email@hidden>)
 >Re: Default Instance of entity in Core Data Document (From: Adam Knight <email@hidden>)

  • Prev by Date: CoreData min and max entity settings
  • Next by Date: Re: NSTableView crashing on scroll+update
  • Previous by thread: Re: Default Instance of entity in Core Data Document
  • Next by thread: applicationWillTerminate and NSDocumentController
  • Index(es):
    • Date
    • Thread