When the app delegate receives a message that the app process is closed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.