Re: How can be my application notified about user defaults changes?
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