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
try out the NSUserDefaultsDidChangeNotification with this code snippet:
- (id)init {
self = [super init];
if(self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(defaultsChanged:)
name:NSUserDefaultsDidChangeNotification
object:nil];
}
return self;
}
- (void)defaultsChanged:(NSNotification *)notification {
// Get the user defaults
NSUserDefaults *defaults = (NSUserDefaults *)[notification object];
NSLog(@"%@", [defaults objectForKey:@"yourIntrestedObject"]);
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}