Re: KVO: I get called on change, but then can't get the object
Re: KVO: I get called on change, but then can't get the object
- Subject: Re: KVO: I get called on change, but then can't get the object
- From: j o a r <email@hidden>
- Date: Sat, 31 May 2008 00:32:30 -0700
On May 31, 2008, at 12:21 AM, Rick Mann wrote:
I registered to observe changes in the "number" column of my tree
controller:
[mItemsController addObserver: self
forKeyPath: @"selection.number"
options: (NSKeyValueObservingOptionNew)
context: NULL];
My -observe: action gets called, but this line
NSLog(@"Value changed %@: %@ (%@)", inKeyPath, inChange, [inObject
selection]);
dumps this to the console:
Value changed selection.number: {
kind = 1;
new = <null>;
} (<_NSControllerObjectProxy: 0x177cb0>)
Note that "new" is null. I would expect it to be the value of the
number.
Search for "NSKeyValueObservingOptionNew" here:
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
Furthermore, this line:
NSLog(@"selection: %@", [inObject valueForKey: @"selection"]);
dumps:
selection: <_NSControllerObjectProxy: 0x177cb0>
But if I change it to @"selection.number", it throws the exception:
"[<NSTreeController 0x1722e0> valueForUndefinedKey:]: this class is
not key value coding-compliant for the key selection.number."
What happens if you call "-valueForKeyPath:" instead of "-valueForKey:"?
j o a r
_______________________________________________
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