NSUserDefaults synchronize not saving on

前端 未结 2 1178
故里飘歌
故里飘歌 2020-12-16 01:41

I have a bug submitted by a tester that if he performs an action and then reboots his phone (by pressing the home and Sleep/Wake button down for a few seconds) the app is no

相关标签:
2条回答
  • 2020-12-16 02:30

    i had gone through the same problem and i identify that i had two reference of [NSUserDefaults standardUserDefaults] object on different classes because nsdefault is a singleton class soo the one called it earlier will have it if u might had already reference of [NSUserDefaults standardUserDefaults] try to finish it from the first reference and let the instance to be free from there and then call the instance at your other class and synchronize hopefully will be done

    0 讨论(0)
  • 2020-12-16 02:41

    In my case, some values I wrote to the NSUserDefaults did persist and some did not. After lots of searching, I noticed the the key-value pair that did not save had a key that was capipatilized, i.e. TheKey v.s theKey. When I changed my key to a camel-cased key (theKey instead of TheKey), the value did persist thru app quit and re-launch. It seems very weird to me why that would be, but it worked in my case.

    0 讨论(0)
提交回复
热议问题