NSUserDefaultsController and KVO
NSUserDefaultsController and KVO
- Subject: NSUserDefaultsController and KVO
- From: David Webster <email@hidden>
- Date: Mon, 8 Dec 2003 22:03:48 +0000
I have a problem getting back a value from NSUserDefaults that I write
to from a popup button bound to NSUserDefaultsController. I need to
have my preference controller notified when this popup changes as I
need to set the state of other widgets based on this popup.
The valueSelection is selectedTag
the binding set to - Shared User Defaults,
the controller key to - values and
the Model Key Path to - DPMetricImperialState
It correctly writes to NSUserDefaults (checked it in my
~\Library\Preferences\myapp.plist - it is an NSNumber with the correct
values). I have added the following to observe changes
[defaultsController addObserver:self
forKeyPath:@"values.DPMetricImperialState"
options:NSKeyValueObservingOptionNew
context:NULL];
When I change the popup - the following is called as expected
- (void) observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqualToString:@"values.DPMetricImperialState"]) {
// gets to here OK
id obj = [change objectForKey:NSKeyValueChangeNewKey];
int tag = [obj intValue];
// its gone into the ether by here but it is the objectForKey:
where I am sure it fails
............
}
}
Any ideas what I am doing wrong? Thanks.
David Webster
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.