OSX NSUserDefaults not Working

ε祈祈猫儿з 提交于 2019-12-04 09:24:19

I found a solution, how to fix it, but not why this happens and no clean, good way so far.

If anybody could explain this and give me a better solution, do so!

  1. the problem was: If you delete the container of a sandboxed app, you also delete the plist for the NSUserDefaults and it's not created again and so NSUserDefaults simply is not working.

  2. the workaround: As I found here https://ind.ie/labs/blog/app-sandbox-updating-nsuserdefaults-fails-after-deleting-apps-container-directory/ it's a problem with the permanent bookmark of the system. Well just to empty the trash does not work for me, but what worked: I simply created the missing file!

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