Tell The Program What To Do When No Save Data Is Found NSUserDefaults, iPhone

前端 未结 2 433
鱼传尺愫
鱼传尺愫 2021-01-16 16:31

I have saved data which was saved using NSUserDefaults. I was under the impression that if there was nothing saved to the key already (first time app is run) it would defaul

2条回答
  •  情深已故
    2021-01-16 17:10

    Call registerDefaults: during your app's launch to set default values for your defaults (awkward to say, but that's how it work). You'll need to call it before any of the code that accesses your defaults. But NSUserDefaults does return 0 or nil for keys that don't exist.

提交回复
热议问题