• 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: Dave Dribin <email@hidden>
  • Date: Fri, 29 Aug 2008 11:41:34 -0500

On Aug 29, 2008, at 11:27 AM, Michael Ash wrote:
This (void *)1091 business seems highly dangerous to me. After all,
what prevents somebody else from using 1091 too? If everybody uses a
pointer value that's guaranteed to be unique (like a unique string
literal) then you know you're safe.

It really just needs to be unique in your class hierarchy, right? But, yeah, it still seems dangerous. I mean, what number do you start using, and what if your class hierarchy changes?


I'm liking Ron's way, because that's guaranteed to be a unique pointer value. I still like the static string, too, but it sounds like in order to ensure uniqueness of the string within a class hierarchy, it may be a good idea to put the class name in there. Two classes using static @"Property Context" should still be unique, unless the linker does some cross-module string literal optimization so that there's only a single @"Property Context" string literal in the entire binary. I don't think it does now, but perhaps with LLVM it'll do more aggressive optimizations like this.

-Dave

_______________________________________________

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

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