In my application when user hits home button I save the data in NSUserDefaults
. Application is running in background. When user re-launches the app I use the method applicationWillEnterForeground
to display the saved data.
However when user double taps on home button and quit the application by selecting minus sign on the app, I need to save different data in that same user defaults. But when I quit the application applicationWillTerminate
is called sometimes and sometimes not.
So, how can I differentiate that the application is just minimized or it is quit?
Whenever user taps one time only and application will go in background at that time applicationDidEnterBackground always calls. In this method you can temporarily update/store your NSUserDefaults value.
If in case, application will again come in foreground with out terminating by using double taps, applicationDidBecomeActive will call, in which you can again update/remove temporarily stored NSUserDefaults value. And if user quits application by double taps, the stored value will be kept with NSUserDefaults.