I'm storing certain values in NSUserDefaults, but after several sessions, I find nil values for those variables whenever I'm retrieving them. It's nowhere that I'm resetti开发者_运维百科ng them in my whole program. How can this happen?
Thanx in advance.
If you register default defaults and set them to nil, in principle an interrupted or mismanaged write to defaults will cause a reversion to the nil default default the next time the app loads. I have never seen that happen, however. Crashes can also corrupt the defaults.
It is more likely that you are simply accidentally setting them to nil somewhere.
They don't change unless you change them; check to make sure you aren't saving nil values to them. You probably are and just don't realize it. The only other way to remove them is to delete the app from the device or simulator.
精彩评论