Skip navigation.
 
mlKVO observeValueForKeyPath, not reflecting changes
FROM : Smith, Steven (MCP)
DATE : Fri Apr 27 16:09:55 2007

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

Related mailsAuthorDate
mlKVO observeValueForKeyPath, not reflecting changes Smith, Steven (MCP… Apr 27, 16:09
mlRe: KVO observeValueForKeyPath, not reflecting changes Jonathan del Strot… Apr 27, 16:25