views:

39

answers:

2

Hi all,

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 resetting them in my whole program. How can this happen?

Thanx in advance.

A: 

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.

TechZen
Thanx TechZen.. My app suffered a couple of crashes during testing.. That might be the cause otherwise I'm setting the defaults only once in my whole application and that's working fine..
neha
A: 

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.

iWasRobbed
Thanx IWasRobbed.. It helped..
neha