Introduction to Default methods in the Swift-appdelegate.swift class

Source: Internet
Author: User

After the project is created, the following methods are provided by default in the Appdelegate class, with the following features:


1, the application executes the first time it is runThis method is only executed once when the app is first run and will not be executed every time the app is activated from the background. (Note: All generally we are here to obtain user licenses, such as local message push licensing, etc.)
1234 func application (application: uiapplication       didfinishlaunchingwithoptions launchoptions: [ : anyobject ) bool {      return true


2, execution when application hangs
The application hangs when a call comes in or locks the screen.

1 funcapplicationWillResignActive(application: UIApplication)


3, the application executes when it enters the background

1 funcapplicationDidEnterBackground(application: UIApplication)


4, the application will go back to the foreground when the execution

1 funcapplicationWillEnterForeground(application: UIApplication)


5, the application executes when it re-enters the active state

1 funcapplicationDidBecomeActive(application: UIApplication)


6, the application will be executed when exiting
This is usually used to save data and do some cleanup before exiting. Refer to my other article, "Swift-the program goes backstage, and the method that is called when the application terminates"

1 funcapplicationWillTerminate(application: UIApplication)

Introduction to Default methods in the Swift-appdelegate.swift class

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.