User Preferences in Objective-C (iOS) - NSUserDefaults
This post is about how to handle user preferences in iOS. User preferences is needed for storing small amounts of data locally and can work out as a small database for your app where you can store simple stuff like score and etc. This is all done via NSUserDefault class. Examples:
Fetching preferences
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; NSString *myParam = [settings stringForKey : @"MY_PARAM"];
Storing preferences
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; [settings setObject : strMyParam forKey : @"MY_PARAM"]; [settings synchronize];
Enjoy :)
Tuesday, May 17, 2011 1:05 PM