Re: observeValueForKeyPath returns null in the change directory???
Re: observeValueForKeyPath returns null in the change directory???
- Subject: Re: observeValueForKeyPath returns null in the change directory???
- From: Jean-Daniel Dupas <email@hidden>
- Date: Sun, 16 Aug 2009 00:31:52 +0200
Le 15 août 2009 à 21:18, Sandro Noel a écrit :
Greetings.
I would like to watch to prefeences change in my application.
so i add these observers as so:
settings = [NSUserDefaultsController sharedUserDefaultsController];
[settings addObserver:self
forKeyPath:@"values.filesPath"
options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
context:NULL];
My observers are registered in applicationDidFinishLaunching.
I do successfully receive the notification for my key path.
but the change directory only returns null values for the old and
the new values, I do not know what i'm doing wrong.
if i fetch the new value directly from the UserDefaultsController
the path did change and I can use it from there.
but I would need the old value to remove the old path from my monitor.
[...]
Any clues would be great !!!
thank you !
Don't know why it behaves like this, but you can probably work around
this by using the NSKeyValueObservingOptionPrior option.
By setting this option, you will receive a notification before the new
value is set, and you can retrieve the old value.
In your observer, you can detect if the notification is the prior one
by querying the NSKeyValueChangeNotificationIsPriorKey key in the
change dictionary.
_______________________________________________
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