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

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
If we assume that the strings and bools are the variables I declare:

Code:
NSString *stringToSave1;
NSString *stringToSave2;
BOOL boolToSave;

// Do whatever gets the above setup.

NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
[defs setObject:stringToSave1 forKey:@"string 1"];
[defs setObject:stringToSave2 forKey:@"string 2"];
[defs setBool:boolToSave forKey:@"bool"]

You can recover them from defaults by

Code:
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
stringToSave1  = (NSString *) [defs objectForKey:@"string 1"];
stringToSave2  = (NSString *) [defs objectForKey:@"string 2"];
boolToSave = [defs boolForKey:@"bool"];

I would not that this is all amazingly clear in the NSUserDefaults documentation. Please check the documentation before asking basic questions. The ability to read and understand the documentation is a key programming skill.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.