How to determine when Settings change on iOS

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).

Leave a Comment