Suchi
Suchi

Reputation: 10039

How to keep NSUserDefault settings in sync with in app settings?

I have used NSUserDefaults to change settings in settings.bundle. I also have in app settings which I update using an observer. This works fine. When I change the setting in app, I update the NSUserDefaults value to reflect it in the settings bundle. But some strange behavior occurs then. I can change it once, but the second time when I switch it to ON it goes back to OFF directly. I am guessing the observer is being called then and something is going wrong. Has anyone seen this behavior? I do not even understand what is really going on.

Upvotes: 2

Views: 1942

Answers (1)

Nico
Nico

Reputation: 3826

Make sure that each time you are done editing the NSUserDefaults you sync them.

[[NSUserDefaults standardUserDefaults] synchronize];

Upvotes: 3

Related Questions