views:

30

answers:

2

How can I store a large float value, like 0.00032012 in the app?? I need to store that number, so when someone click a save preferences button, it stores a variable. Then when I relaunch the app, it will remember that number and post it in a text field.

I was thinking of using plist, but how can I store variables in the plist??? Examples?

Any ideas???

Elijah

+3  A: 

UserDefaults is the best way to store preferences like this. You can store Cocoa's built-in NSNumber objects by default, or you can use NSData if you need more storage space.

e.James
Can you show an example??
Elijah W.
See Georg Fritzsche's answer. He has updated with sample code now.
e.James
+4  A: 

Take a look at NSUserDefaults and the user defaults guide:

NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
// save:
[defs setDouble:0.0032 forKey:@"myNumber"];
// load:
double d = [defs doubleForKey:@"myNumber"];
Georg Fritzsche