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 ver
Use &PropertyObservationContext as the context. This way you could
"po *(id *)context" in gdb for a human readable context.
That was my main concern of using the address of a static variable,
but combining the two approaches works nicely.
Keith
_
On Aug 29, 2008, at 12:35 PM, Dave Dribin wrote:
On Aug 29, 2008, at 12:23 PM, j o a r wrote:
The penalty for using constant strings is that they will end up
wasting space in your binary...
Rons suggestion is probably optimal.
I'm definitely leaning towards that way, now. Though I may combi
On Aug 29, 2008, at 12:23 PM, j o a r wrote:
The penalty for using constant strings is that they will end up
wasting space in your binary...
Rons suggestion is probably optimal.
I'm definitely leaning towards that way, now. Though I may combine
both for debugging.
static NSString *Proper
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 ju
On Fri, Aug 29, 2008 at 12:41 PM, Dave Dribin <[EMAIL PROTECTED]> wrote:
> 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 guara
On Aug 29, 2008, at 12:43 PM, Keith Duncan wrote:
After all, what prevents somebody else from using 1091 too?
Nothing whatsoever. But that isn't a problem. So long as the
observation context remains internal it doesn't have to be
universally unique.
It has to be unique within an inherita
On Aug 29, 2008, at 7:56 AM, Dave Dribin wrote:
Since context is a void *, it also seems best practice to just use
some unique pointer values. For example, mmalc's Graphics Bindings
sample does this:
static void *PropertyObservationContext = (void *)1091;
static void *GraphicsObservationCo
On Aug 29, 2008, at 10:56 AM, Dave Dribin wrote:
It seems that KVO best practice is to use the "context" in
observeValueForKeyPath:ofObject:change:context: to differentiate
between different key paths, rather than check key path strings for
equality. Since context is a void *, it also seem
After all, what prevents somebody else from using 1091 too?
Nothing whatsoever. But that isn't a problem. So long as the
observation context remains internal it doesn't have to be universally
unique.
If you're performing [anotherObjectNotSelf addObserver... then yes,
I'd make sure that t
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 rea
On Fri, Aug 29, 2008 at 10:56 AM, Dave Dribin <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> It seems that KVO best practice is to use the "context" in
> observeValueForKeyPath:ofObject:change:context: to differentiate between
> different key paths, rather than check key path strings for equality. Since
On Aug 29, 2008, at 8:13 AM, Dave Dribin wrote:
On Aug 29, 2008, at 10:03 AM, Phil wrote:
On Sat, Aug 30, 2008 at 2:56 AM, Dave Dribin <[EMAIL PROTECTED]>
wrote:
Is there some benefit to using number values over string
constants, or is it
just stylistic differences?
Using NSStrings (or
On Aug 29, 2008, at 10:03 AM, Phil wrote:
On Sat, Aug 30, 2008 at 2:56 AM, Dave Dribin <[EMAIL PROTECTED]>
wrote:
Is there some benefit to using number values over string constants,
or is it
just stylistic differences?
Using NSStrings (or any other object) will work fine, but comparing
two
On Sat, Aug 30, 2008 at 2:56 AM, Dave Dribin <[EMAIL PROTECTED]> wrote:
> Is there some benefit to using number values over string constants, or is it
> just stylistic differences?
>
Using NSStrings (or any other object) will work fine, but comparing
two primitive numbers is a lot faster than comp
Hi all,
It seems that KVO best practice is to use the "context" in
observeValueForKeyPath:ofObject:change:context: to differentiate
between different key paths, rather than check key path strings for
equality. Since context is a void *, it also seems best practice to
just use some unique
16 matches
Mail list logo