I have a requirement to store the present state of application using UIApplicationWillTerminateNotification and NSUserDefaults where i need to load the application with the previous state when the user has logged out from the Application. My application is a TabBar Based Application and inturn its a Navigation Controller. I need to store the present view controller loaded in the navigation Controller and the present tab where the Navigation Controller is present. My application works for different user and i need to store the state of the application particular to the user. So, i need to store the user data as well. I searched it in StackOverflow and Googled it to find that we need to use something like NSUserDefaults and UIApplicationWillTerminateNotification is necessary for the same. This is the first time i am coming across these stuff. Can someone please post some tutorial or any sample code on how to get my requirement done?
I have a requirement to store the present state of application using UIApplicationWillTerminateNotification and
Share
You can register for the notifications themselves (see NSNotificationCenter) and write your save/load code there, or you can put your code in the AppDelegate, which provides these hooks:
Look in the AppDelegate.m file, and you can see stub implementation with some documentation as to how they are to be used.
In there, you will simply write your data to, and read it from NSUserDefaults, as appropriate.