Save :
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// saving an NSString
[prefs setObject:@"TextToSave" forKey:@"stringKey"];
// saving an NSInteger
[prefs setInteger:100 forKey:@"integerKey"];
// saving a Float
[prefs setFloat:1.2345678 forKey:@"floatKey"];
Retrieve :
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// getting an NSString
NSString *myString = [prefs stringForKey:@"
stringKey
"];
// getting an NSInteger
NSInteger myInt = [prefs integerForKey:@"
integerKey
"];
// getting an Float
float myFloat = [prefs floatForKey:@"
floatKey
"];
No comments:
Post a Comment