You can listen for NSUSerDefaultsDidChange-notifications with this:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(defaultsChanged) name:NSUserDefaultsDidChangeNotification object:nil];
Whenever the NSUserDefaults changes, defaultsChanged
will be called.
Don't forget to call [[NSNotificationCenter defaultCenter] removeObserver:self];
when you want to stop listening for these notifications (you should also do this when object gets deallocated).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…