views:

75

answers:

1

Hi, I'm doing a iphone application and when the user quit the application and return in the application later, I want he return at the same place in the application before he quit. How I do this? Is it serialization?

thanks Alex

A: 

It's a little different than serialization. What you want to do is save the app details in NSUserDefaults. For example, if you have a tab view, save the index of the last tab used in the user defaults.

If you have a table view, you can use serialization to save the actual information in the table to present back to the user when they start the app again.

nevan
But example, if I have a navigation controller, and the user is at the view 7 in the hiearchie of the navigation controller, and when he quit and return back in the apps, I want he start at the view 7, is it with NSUserDefaults??
Alex
You would have to save the user's current location in the view to `NSUserDefaults`, then when your application starts, either in `-init` or `-awakeFromNib` read that information back in so the view knows what step to start with.
Paul
but what type of object I save with the NSUserDefaults, can I do this:NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:self.navigationController.view forKey:@"view"];and if it's possible to do this, what is the method the get my view with the nsuserdefaults
Alex
This question has a really good answer to your problem: http://stackoverflow.com/questions/1811696/how-to-preserve-iphone-application-state-before-terminating-the-application
nevan