• 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: Core Data, to-many relationships, and object graph consistency
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data, to-many relationships, and object graph consistency


  • Subject: Re: Core Data, to-many relationships, and object graph consistency
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 15 Jun 2009 10:58:11 -0700

On Jun 15, 2009, at 06:43, Sebastian Celis wrote:

I believe I found my issue. In my SCBook class I was overriding
didChangeValueForKey:withSetMutation:usingObjects: so that I could
store an NSString containing a comma-separated list of tags associated
with the book. Apparently this is a very bad way to do it. I missed
the big warning in the documentation which states that this method
should not be overridden. What is the correct way to do this from
inside of the SCBook class?

If the comma-separated list is just for display in the user interface, you could generate it on the fly. Use 'keyPathsForValuesAffectingTagList' (or whatever) to ensure that the proper KVO notifications get sent when the underlying bookTag objects change.


If you really want to store the comma-separated list, you can write your own set accessor overrides (addTagsObject, removeTagsObject, addTags, removeTags) and rebuild the string in the accessors. The only trick here (apart from following the documented pattern for writing the accessors) is to realize that the accessors are also called at undo time, so accessors with a side effect of updating a different property can be problematical unless you're careful.


_______________________________________________

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: Core Data, to-many relationships, and object graph consistency
      • From: Sebastian Celis <email@hidden>
References: 
 >Core Data, to-many relationships, and object graph consistency (From: Sebastian Celis <email@hidden>)
 >Re: Core Data, to-many relationships, and object graph consistency (From: Quincey Morris <email@hidden>)
 >Re: Core Data, to-many relationships, and object graph consistency (From: Sebastian Celis <email@hidden>)
 >Re: Core Data, to-many relationships, and object graph consistency (From: Sebastian Celis <email@hidden>)

  • Prev by Date: Re: ANN: Rosetta Booster Beta 1.0.1a (reference [NSTask] -launch return)
  • Next by Date: Re: Open a file when Application launch
  • Previous by thread: Re: Core Data, to-many relationships, and object graph consistency
  • Next by thread: Re: Core Data, to-many relationships, and object graph consistency
  • Index(es):
    • Date
    • Thread