What is the delegate method for detecting when application was closed.
I mean when user tap this button:
You can implement the -applicationWillTerminate: method of your UIApplicationDelegate
delegate to respond to termination events. However, it's not guaranteed to be called in all cases, so you should not rely on it being called. According to the iOS App Programming Guide:
If your app is running (either in the foreground or background) at termination time, the system calls your app delegate’s
applicationWillTerminate:
method so that you can perform any required cleanup. You can use this method to save user data or app state information that you would use to restore your app to its current state on a subsequent launch. Your method has approximately 5 seconds to perform any tasks and return. If it does not return in time, the app is killed and removed from memory.Important: The
applicationWillTerminate:
method is not called if your app is currently suspended.