1. App executes main function first;

  1. Execute the UIApplicationMain function. The fourth parameter specifies the UIApplication proxy, and the third parameter specifies the UIApplication class name;

  2. Inside UIApplicationMain

3.1 Creating a UIApplication instance. This UIApplication is a singleton object, a UIApplication object for an iOS application;

3.2 UIApplication object is the symbol of the application;

3.3 Start a Main loop;

3.4 Create a UIApplication delegate object that listens for the UIApplication life cycle;

3.5 When the UIApplication life cycle changes, different messages are sent to the AppDelegate.

3.6 Every application has its own UIWindow, which inherits from UIView. UIView: A view. All the things you can see and touch on the screen are UIViews, like buttons, labels, text input fields, etc. UIViewController: There is an internal UIView view by default. UIViewController is responsible for managing the lifecycle of UIView, assembling data to display on UIView, and handling UIView events. UIWindow contains the status bar and the first UIViewController, rootViewController.

Below is the relational view of MVC

Main Run loop handles transaction schematics

UIApplication life cycle

1. When running the program for the first time

DidFinishLaunchingWithOptions: program to load.

ApplicationDidBecomeActive: enter the activated state, can interact with the user.

When you hit the home button

ApplicationWillResignActive: quit the activated state, can’t interact with the user.

ApplicationDidEnterBackground: enter the backstage, ios support multitasking, after namely not break after application into the background.

2. Click again to enter the program

ApplicationWillEnterForeground: into the front desk.

ApplicationDidBecomeActive: have entered the activated state. 支那

3. When the program exits, it is executed regardless of whether it exits normally

applicationWillTerminate: