I\'m creating a simple app to simply save a person\'s name and a number associated with this person. I\'ve created a class for person like this:
@interface P
Easy to do with NSUserDefaults
, here's some code to get you started:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
appDelegate.lastPerson.name = [defaults stringForKey:@"Name"];
appDelegate.lastPerson.serial = [defaults stringForKey:@"Serial"];
[window addSubview:[flipViewController view]];
[window makeKeyAndVisible];
}
-(void)applicationWillTerminate:(UIApplication *)application {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setString:appDelegate.lastPerson.name forKey:@"Name"];
[defaults setString:appDelegate.lastPerson.serial forKey:@"Serial"];
[defaults synchronize];
}
You can check if either of the strings are nil after loading which will indicate no stored value and you should then ask the user for input.