NSUserDefaults is your friend when you need to save a small amount of data. Here is some sample code for saving various data types.
01 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
02 | |
03 | //Setting defaults |
04 | [defaults setInteger:1 forKey:@ "myint" ]; |
05 | [defaults setObject:@ "my string" forKey:@ "mystring" ]; |
06 | [defaults setFloat:100.23 forKey:@ "myfloat" ]; |
07 | |
08 | //Getting defaults |
09 | int myint = [defaults intForKey:@ "myint" ]; |
10 | NSString *mystring = [defaults intForKey:@ "mystring" ]; |
11 | float myfloat = [defaults floatForKey:@ "myfloat" ]; |
0 Comments