iPhone Dev : Persisting Values
January 30, 2010 1 Comment
Well i think most of us rely upon using SQLite for storing variables and data for our iPhone apps,but what if we only want to score 2-3 values.Like high score in some game or the number of visits to app.Setting up whole SQLite for just 2-3 variables doesn’t seem logical.
To solve this we use [NSUserDefaults standardUserDefaults].Basically this is used to store the default values and can also be used to save values associated with keys.
To Save Variables:
So if you have a HighScore value you can save it for some key,in this case”HighScore”.
To Retrieve Variables:
And that’s it.Simple and no need to setup SQLite for storing your simple variables.