• 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: What to use observeValueForKeyPath: context
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What to use observeValueForKeyPath: context


  • Subject: Re: What to use observeValueForKeyPath: context
  • From: j o a r <email@hidden>
  • Date: Fri, 29 Aug 2008 10:23:05 -0700


On Aug 29, 2008, at 9:56 AM, Michael Ash wrote:

It really just needs to be unique in your class hierarchy, right?

True, but not particularly useful. Your class hierarchy includes NSObject, which is free to observe whatever it feels like in your objects.


No this is not generally true, so just forget about that and instead ensure that the context pointers are globally unique.


If you use a constant string, you should make sure that the
string *contents* are unique, in order to ensure uniqueness of the
pointer to it. So don't call it @"context", use @"MyFunkyClass KVO
observer context". After all there's no penalty for being verbose in
this case. Of course using a pointer to a global solves this too.


The penalty for using constant strings is that they will end up wasting space in your binary...
Rons suggestion is probably optimal.



j o a r


_______________________________________________

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: What to use observeValueForKeyPath: context
      • From: Chris Kane <email@hidden>
    • Re: What to use observeValueForKeyPath: context
      • From: Dave Dribin <email@hidden>
References: 
 >What to use observeValueForKeyPath: context (From: Dave Dribin <email@hidden>)
 >Re: What to use observeValueForKeyPath: context (From: "Michael Ash" <email@hidden>)
 >Re: What to use observeValueForKeyPath: context (From: Dave Dribin <email@hidden>)
 >Re: What to use observeValueForKeyPath: context (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Help with "ditto"
  • Next by Date: Re: Help with "ditto"
  • Previous by thread: Re: What to use observeValueForKeyPath: context
  • Next by thread: Re: What to use observeValueForKeyPath: context
  • Index(es):
    • Date
    • Thread