How to save Application State using NSUserDefaults in iPhone?
Posted
by keith
on Stack Overflow
See other posts from Stack Overflow
or by keith
Published on 2010-06-08T06:15:23Z
Indexed on
2010/06/08
6:22 UTC
Read the original article
Hit count: 232
iphone
|nsuserdefaults
Hello Everyone,
Following is what i am doing:
- (void) applicationWillTerminate: (UIApplication*) application {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:navigationController.viewControllers
forKey:@"diabetesstate"];
}
- (void) applicationDidFinishLaunching: (UIApplication*) application {
NSMutableArray *state = [[NSUserDefaults standardUserDefaults]
objectForKey:@"diabetesstate"];
if (state == nil) {
//Will initialize a new controller and put it as root view controller
}
else {
[navigationController setViewControllers:state animated:NO];
}
}
© Stack Overflow or respective owner