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

Default Instance of entity in Core Data Document


  • Subject: Default Instance of entity in Core Data Document
  • From: Frank Schmitt <email@hidden>
  • Date: Tue, 31 Jul 2007 10:26:51 -0700

I'm writing a Core Data Document-based application that needs to have a single instance of one or two settings saved with every document. The way I'd like to do this is to add an entity (say "MySettings") to the data model managed by an NSObjectController, whose attributes are the various settings I need to save. I would then bind a series of UI elements to the object controller, and the values entered into the UI would automagically make their way into the file.

I've run into two snags along the way:

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.

The second snag is that modifying the file after it's created always brings up a "Save Changes?" sheet. I imagine I could reset this with updateChangeCount, but that seems hackish. Is that in fact the right way to do this?

Ideally I could change the "blank slate" state of the managed object context to include one instance of the entity with the default values that I've assigned in the data model editor. Is there a way to do that?

Thanks,

-Frank
_______________________________________________

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


  • Follow-Ups:
    • Re: Default Instance of entity in Core Data Document
      • From: Adam Knight <email@hidden>
    • Re: Default Instance of entity in Core Data Document
      • From: mmalc crawford <email@hidden>
  • Prev by Date: Re: Moveable/Resizable "Box" views and blurry frame
  • Next by Date: Re: Posting NSApplicationDidFinishLaunchingNotification fails, Application crashes on Intel Macs
  • Previous by thread: Flipped view confusion
  • Next by thread: Re: Default Instance of entity in Core Data Document
  • Index(es):
    • Date
    • Thread