• 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
Re: How can be my application notified about user defaults changes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can be my application notified about user defaults changes?


  • Subject: Re: How can be my application notified about user defaults changes?
  • From: Steven Riggs <email@hidden>
  • Date: Fri, 10 Oct 2008 21:22:40 -0400

Alexander,

If you have a bunch of keys in your defaults, try only observing the specific key. Like this...

- (void)awakeFromNib
{
	//setup key observer here
	[[NSUserDefaults standardUserDefaults] addObserver:self
						forKeyPath:@"AppleMeasurementUnits"
						options:NSKeyValueObservingOptionNew
						context:NULL];
}

// ------------------------------------------------------------------------------
// Do this when the observed keys change:
// ------------------------------------------------------------------------------
- (void) observeValueForKeyPath:(NSString *) keyPath ofObject:(id) object
change:(NSDictionary *) change context:(void *) context
{
//was one of the selectedView buttons pressed?
if([keyPath isEqual:@"AppleMeasurementUnits"])
{
//Stuff to do when AppleMeasurementUnits changes
}
}


All the best,
	Steven Riggs
	http://www.stevenriggs.com

NSUserDefaultsDidChangeNotification

On 09-Oct-08, at 5:51 PM, Alexander Shmelev wrote:

Hello,

My program UI depends on what measurement units are used.
How can I get notification when "AppleMeasurementUnits" have been
changed by "Preferences" application?

Best regards, Alexander.
_______________________________________________

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
_______________________________________________

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


  • Prev by Date: Add animation layer and then remove animation layer
  • Next by Date: Re: Opening a document from stationery
  • Previous by thread: Re: How can be my application notified about user defaults changes?
  • Next by thread: [NSApp stop:]
  • Index(es):
    • Date
    • Thread