View Full Version : What is preferred method of data storage?

Aug 29, 2008, 06:46 PM
This may seem like a stupid questions, but I couldn't find an example of it anywhere. Is there a specific way that user preferences should be stored?

I basically have some simple attributes like a background image name that I would like to save and then load next time the user opens the app.

Aug 29, 2008, 07:20 PM

Aug 29, 2008, 07:50 PM
Awesome, thanks. And for those that might need more than a one-word reply (although it's amazing what one word can tell you):

NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];

if (standardUserDefaults) {
[standardUserDefaults setObject:myString forKey:@"Prefs"];
[standardUserDefaults synchronize];

NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *val = nil;

if (standardUserDefaults)
val = [standardUserDefaults objectForKey:@"Prefs"];

return val;

Aug 30, 2008, 12:42 AM
I just save all the user info as an array within an NSData object on a file in documents directory.