Re: NSKeyValueChangeNewKey returning NSNull
Re: NSKeyValueChangeNewKey returning NSNull
- Subject: Re: NSKeyValueChangeNewKey returning NSNull
- From: Mike Abdullah <email@hidden>
- Date: Fri, 21 Dec 2007 22:06:30 +0000
NSNull is used by KVO to represent a nil value.
Mike.
On 21 Dec 2007, at 18:50, Kai Brüning wrote:
Hi,
I have a case in which a KVO change dictionary always contains
NSNull under NSKeyValueChangeNewKey and no idea why.
Observation is established like this:
[objectToObserve addObserver:self forKeyPath:@"visiblePage"
options:NSKeyValueObservingOptionNew
context:whatever];
objectToObserve has this pair of accessors:
- (NSNumber*) visiblePage {
return [NSNumber numberWithInt:_visiblePage];
}
- (void) setVisiblePage:(NSNumber*)value {
_visiblePage = [value intValue];
}
which are declared in the interface, too:
- (NSNumber*) visiblePage;
- (void) setVisiblePage:(NSNumber*)value;
_visiblePage is an iVar of type int.
Any idea why the change dictionary would contain NSNull for
NSKeyValueChangeNewKey in this case?
Note: - (NSNumber*) visiblePage is not called during the whole
change process, but observeValueForKeyPath:ofObject:change:context:
is called on the observing object, just with the defective change
dictionary.
In a very similar case (identical observed class, slightly different
observer) everything works well.
The workaround is obvious (using valueForKey: instead of depending
on the change dictionary) and works, but I'd would prefer to
understand this issue.
This is all with Xcode 3 under 10.5.1 with GC off.
Best,
Kai
_______________________________________________
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
_______________________________________________
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