• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
observeValueForKeyPath returns null in the change directory???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: observeValueForKeyPath returns null in the change directory???
      • From: "Sean McBride" <email@hidden>
    • Re: observeValueForKeyPath returns null in the change directory???
      • From: Kyle Sluder <email@hidden>
    • Re: observeValueForKeyPath returns null in the change directory???
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: initWithCoder but I do not have nib file
  • Next by Date: Re: Timer in drawing loop performance problems
  • Previous by thread: Re: initWithCoder but I do not have nib file
  • Next by thread: Re: observeValueForKeyPath returns null in the change directory???
  • Index(es):
    • Date
    • Thread