开发者

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

开发者 https://www.devze.com 2023-03-26 02:57 出处:网络
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 upda

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];

0

精彩评论

暂无评论...
验证码 换一张
取 消