NSUserDefaults
1. Storing Data
1. Storing Data
// create a standardUserDefaults variable
NSUserDefaults * standardUserDefaults = [NSUserDefaults
standardUserDefaults];
|
// saving an NSString
[standardUserDefaults setObject:@"mystring" forKey:@"string"]; |
// saving an NSInteger
[standardUserDefaults setInteger:42 forKey:@"integer"]; |
// saving a Double
[standardUserDefaults setDouble:3.1415 forKey:@"double"]; |
// saving a Float
[standardUserDefaults setFloat:3.1415 forKey:@"float"]; // synchronize the settings |
[standardUserDefaults synchronize];
|
2. Retrieving Data
// create a standardUserDefaults variable
NSUserDefaults *standardUserDefaults = [NSUserDefaults
standardUserDefaults];
// getting an NSString object
NSString *myString = [standardUserDefaults stringForKey:@"keyToLookupString"]; // getting an NSInteger object |
NSInteger myInt = [standardUserDefaults
integerForKey:@"integerKey"];
|
// getting an Float object
|
float myFloat = [standardUserDefaults floatForKey:@"floatKey"];
|
--------------------------------------------------------
ReplyDeleteNice Post ..!! I really i like the way of your writing this post. You have shared a very interesting and informative post about Mobile platform .. keep Updating..!!
iPhone App Development :: && ::Mobile and Web Application Development
Please, accept my vehement protestation of gratitude, dear…..
ReplyDelete