KVO observeValueForKeyPath, not reflecting changes
-
Hello folks,
I've got a pretty simple (or so I thought) KVC/KVO where I'm wanting
to observe
changes in an NSTableView column.
I register as an observer with
:
[theArrayController addObserver:self forKeyPath:@"selection.dValue"
options:(NSKeyValueObservingOptionNew |
NSKeyValueObservingOptionOld)
context:@"dValue"];
:
Then I have the KVO:
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void*)context
{
if ([keyPath isEqualToString:@"selection.dValue"] && context ==
@"dValue")
{
NSLog(@"change = %@", change);
id v = [change valueForKey:NSKeyValueChangeNewKey];
NSLog(@"v=%@", v);
}
}
When I change a value in "dValue"-column the
observeValueForKeyPath:ofObject:change:context always returns:
change = {kind = 1; new = <null>; old = <null>; }
v=<null>
Searching through the different lists I've found one that said this was
a bug but that was in 2004.
My code snippet is almost exactly what is in the "Key-Value Observing
Programming Guide"
Any ideas? Or does anyone know if this IS a bug and any work-arounds?
Thanks in advance,
Steven -
> observeValueForKeyPath:ofObject:change:context always returns:
>
> change = {kind = 1; new = <null>; old = <null>; }
> v=<null>
>
> Searching through the different lists I've found one that said this
> was
> a bug but that was in 2004.
Yep, still a bug, still unfixed, no known workarounds (well, short of
keeping track of the old values yourself).
It's bewildering that this hasn't been fixed yet.
Jon


