Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: KVO and the observeValueForKeyPath bottleneck
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO and the observeValueForKeyPath bottleneck



On Jul 17, 2006, at 9:00 PM, Chris Kane wrote:

If you assume that @"" string constants are NOT globally uniqued in a binary, but only to a given compilation unit, then ThisClassUniqueObservationContext could be a constant string:

static NSString * ThisClassUniqueObservationContext = @"MyContext";

Even if the strings are globally uniqued across the entire binary, assuming a FBFroobazle class, something like this is probably good enough:


static NSString * FBFroobazzleValueObservationContext = @"FBFroobazzleValueObservationContext";

Certainly better than

static void * FBFroobazzleValueObservationContext = (void *)2192;

There is the chance that someone else will use the string @"FBFroobazzleValueObservationContext" as an observation context elsewhere in the inheritance tree, but I think that a) it would be a programmer error b) is probably not worth losing any sleep over.

And there is certainly a smaller chance of a collision than with an arbitrarily picked number.

Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: KVO and the observeValueForKeyPath bottleneck (From: Matt Neuburg <email@hidden>)
 >Re: KVO and the observeValueForKeyPath bottleneck (From: Chris Kane <email@hidden>)
 >Re: KVO and the observeValueForKeyPath bottleneck (From: Jakob Olesen <email@hidden>)
 >Re: KVO and the observeValueForKeyPath bottleneck (From: Chris Kane <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.