Posts Tagged ‘XCode’

Lesen/Schreiben NSUserDefaults

Posted: 25. Januar 2014 in Development, iOS
Tags: , ,

Lesen

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

NSString *myString = [prefs stringForKey:@"lookupKey"];
NSInteger myInt = [prefs integerForKey:@"lookupKey"];
float myFloat = [prefs floatForKey:@"lookupKey"];

Schreiben

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

[prefs setObject:@"TextToSave" forKey:@"lookupKey"];
[prefs setInteger:42 forKey:@"lookupKey"];
[prefs setDouble:3.1415 forKey:@"lookupKey"];
[prefs setFloat:1.2345678 forKey:@"lookupKey"];