NSUserDefaults not saving

前端 未结 4 1629
迷失自我
迷失自我 2021-01-12 23:14

I am having a problem in my sprite kit app where my NSUserDefaults variable is not working. In createSceneContents (which I know is being called)

4条回答
  •  佛祖请我去吃肉
    2021-01-13 00:07

    When you say you "stop the program", what do you mean? Are you running in the debugger and killing the app and rerunning it again? NSUserDefaults doesn't persist your changes immediately. Either call [defaults synchronize] after writing important data or at least add such a call to your app delegate's applicationDidEnterBackground method. And then be sure you put your app in the background before killing it to ensure the data is written first.

提交回复
热议问题