• 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: Copying Managed Objects from App to Doc MOContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: Copying Managed Objects from App to Doc MOContext


  • Subject: re: Copying Managed Objects from App to Doc MOContext
  • From: Ben Trumbull <email@hidden>
  • Date: Mon, 22 Dec 2008 00:18:38 -0800

My app maintains in its managed object context an array of, say,
Potato objects.  The potatoes in this central managed object context
come and go occasionally -- someone might throw in a new one, or eat
one.  An archived potato is low in calories, consisting of a half
dozen numbers or short strings.

My persistent documents can also contain several potatoes.  To set
one, user clicks a popup menu in the document window.  The popup is
populated by the potatoes currently available in the central managed
object context.

Because the potatoes in this popup are inserted into the central
managed object context, however, I cannot simply "set" one of them
into my document when the user makes their seledtion.  I implement a
custom setter which inserts a ^new^ potato into the document's managed
object context, and copies to it all of the attributes from the
selected potato.

Looks OK to me, but having never seen anything like this, I was
wondering if I'm seeing OK today.

It's fine.

    /* The following one-liner will almost work:
     return [self dictionaryWithValuesForKeys:attributes] ;
     Unfortunately, instead of omitting pairs for which the values
are nil,
     it inserts keys with values of NSNull.  So, I use my own
implementation:
     */

We tried omitting pairs with nil values, and stuff broke. Like views didn't get updated because iterating over the values during setting with (nil = missing) meant nil values didn't get reset. Like with undo or bindings. Your setter here has that issue. You may prefer that behavior, but we found it even more problematic than forcing clients to check for NSNull.


- Ben

_______________________________________________

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


  • Prev by Date: Re: os x gui scripting
  • Next by Date: re: Core Data File Encryption
  • Previous by thread: Re: Copying Managed Objects from App to Doc MOContext
  • Next by thread: (no subject)
  • Index(es):
    • Date
    • Thread