observeValueForKeyPath returns null in the change directory???
observeValueForKeyPath returns null in the change directory???
- Subject: observeValueForKeyPath returns null in the change directory???
- From: Sandro Noel <email@hidden>
- Date: Sat, 15 Aug 2009 15:18:55 -0400
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.
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
[keyPath retain];
[change retain];
if ([keyPath isEqual:@"values.filesPath"]) {
NSString *old = [change objectForKey:NSKeyValueChangeOldKey];
NSString *new = [change objectForKey:NSKeyValueChangeNewKey];
// both are NSNull
[fileMonitor removePath:old];
[fileMonitor addPath:new];
// this works fine....
[fileMonitor addPath:[[settings values] valueForKey:@"filesPath"]];
}
[change release];
[keyPath release];
}
Any clues would be great !!!
thank you !
Sandro Noël
email@hidden
Mac OS X : Swear by your computer, not at it.
P
-Pensez vert! avant d’imprimer ce courriel.
-Go Green! please consider the environment before printing this email.
_______________________________________________
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