Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

darkpegasus

macrumors newbie
Original poster
Jul 18, 2008
3
0
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.
 

darkpegasus

macrumors newbie
Original poster
Jul 18, 2008
3
0
Awesome, thanks. And for those that might need more than a one-word reply (although it's amazing what one word can tell you):

-(void)saveToUserDefaults:(NSString*)myString
{
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];

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

-(NSString*)retrieveFromUserDefaults
{
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *val = nil;

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

return val;
}
 

jsnuff1

macrumors 6502a
Oct 4, 2003
730
340
NY
I just save all the user info as an array within an NSData object on a file in documents directory.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.