Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What to use observeValueForKeyPath: context



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >What to use observeValueForKeyPath: context (From: Dave Dribin <email@hidden>)
 >Re: What to use observeValueForKeyPath: context (From: "Michael Ash" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.