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
sandro.n...@mac.com
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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to