I\'m developing an iOS application with latest SDK.
I want to know when a property on NSUserDefaults
changes it value.
I have found this, but it
Use NSUserDefaultsDidChangeNotification for notification about change in User defaults:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(defaultsDidChange:) name:NSUserDefaultsDidChangeNotification
object:nil];
// notification
- (void)defaultsDidChange:(NSNotification *)aNotification
{
//
}
Use KVO for notification about specific change in User defaults:
[[NSUserDefaults standardUserDefaults] addObserver:self
forKeyPath:@"APXMyPropertyIamInterestedInKey" options:NSKeyValueObservingOptionNew
context:NULL];
// KVO handler
-(void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject
change:(NSDictionary *)aChange context:(void *)aContext
{
//
}