I have used NSUserDefaults to change settings in settings.bundle. I also have in app settings which I u开发者_运维技巧pdate 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.
Make sure that each time you are done editing the NSUserDefaults you sync them.
[[NSUserDefaults standardUserDefaults] synchronize];
精彩评论