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 relaunc开发者_StackOverflow社区h 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???
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"];
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.
精彩评论