Re: What to use observeValueForKeyPath: context
Re: What to use observeValueForKeyPath: context
- Subject: Re: What to use observeValueForKeyPath: context
- From: Chris Kane <email@hidden>
- Date: Fri, 29 Aug 2008 16:16:12 -0700
On Aug 29, 2008, at 10:23, j o a r wrote:
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.
Even more optimal than...
static NSString *ABCFooPropertyObservingContext;
is this:
static char ABCFooPropertyObservingContext;
and then still using &ABCFooPropertyObservingContext as the context
value. If nothing ends up being packed up tight right after that
char, due to data alignment, well then you still haven't lost anything.
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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