Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)
After we set up a new project in Xcode, the Appdelegate class will find many callback methods related to app status (you can also use app status notifications, of course), where you'll see a applicationwillterminate: ( UIApplication *) Application callback method, literally the method should be called when the app is about to end.
But when we run the program in Xcode and click Stop Debugging to close the app, the method is not called.
We run the app in Xcode, and when we press the home key into the background, we bring up the Task manager interface and don't call the method when we close the app.
So when is the method called?
The answer is simple: This method is only called when the app is set to not go into the suspended state, after the app has entered the background.
We can add a new item to the app's main.plist and set it to Yes:
UIApplicationExitsOnSuspend = YES
This means that the app will not go into a pending state and end it once it enters.
Now run the app and press the Home button, you will find that the method has been called and your app has been ended.
When the app delegate receives a message that the app process is closed