Objective-C NSUserDefaults caching prevents another app from accurately reading changes

拜拜、爱过 提交于 2019-12-02 01:38:52

You should be able to call +[NSUserDefaults resetStandardUserDefaults] in the second program to force +[NSUserDefaults standardUserDefaults] to create a new instance and reload values from disk the next time it's called. Calling -synchronize in the first program is the correct approach to make sure the updated defaults are written to disk (I'm not sure how NSUserDefaultsController behaves in this regard).

Note that calling +[NSUserDefaults resetStandardUserDefaults] every time you access the standardUserDefaults may result in a performance penalty if you do so frequently, since it will presumably mean a disk hit on every read.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!