NSUserDefaults is one of simplest ways to store your configuration/settings of your iPhone/iPad application. You don't have to create a plist or work with the file system, it encapsulates all of that.
The value that is to be stored can be instance of NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary. Internally this API knows how to serialize/deserialize the instance.
<!--break-->
- // get the handle
- NSUserDefaults*defaults =[NSUserDefaults standardUserDefaults];
- NSString*key =@"username";
- NSString*value =@"john";
- // set the value
- [defaults setObject:value forKey:key];
- // save it
- [defaults synchronize];
- // Get the result
- NSString*retrievedValue =[defaults stringForKey:key];