1.application Boot Path
1Supporting Files--->main.m2 intMainintargcChar*argv[])3 {4 @autoreleasepool {5 /*6 argc: Number of parameters passed in by the system or user7 argv: Actual parameters passed in by the system or user8 9 */Ten //return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Njappdelegate class])); One A //return Uiapplicationmain (argc, argv, @ "UIApplication", Nsstringfromclass ([Njappdelegate class])); - - /* the 1. Create a UIApplication object based on the third parameter passed in - 2. Based on the fourth incoming agent that created the UIApplication object - 3. Set the proxy object that you just created for UIApplication - 4. Turn on an event loop + */ - returnUiapplicationmain (argc, argv,@"uiapplication",@"njappdelegate"); + } A}
2.application life cycle
1 //called when the application is finished (automatically called by the system)2-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) Launchoptions3 {4 //Override point for customization after application launch.5NSLog (@"didfinishlaunchingwithoptions");6 returnYES;7 }8 //called when it is about to lose its active state (loses focus, cannot interact)9- (void) Applicationwillresignactive: (UIApplication *) ApplicationTen { OneNSLog (@"resignactive"); A } - - //regain focus (ability to interact with users) the- (void) Applicationdidbecomeactive: (UIApplication *) Application - { - -NSLog (@"becomeactive"); + } - + //called when the application enters the background A //The application's data is typically stored in this method, as well as the state at- (void) Applicationdidenterbackground: (UIApplication *) Application - { - -NSLog (@"Background"); - } - in //called when the application is about to enter the foreground - //typically restores the application's data in this method, as well as the state to- (void) Applicationwillenterforeground: (UIApplication *) Application + { - theNSLog (@"Foreground"); * } $ Panax Notoginseng //This method is called when the application is about to be destroyed - //Note: This method cannot be called if the application is in a suspended state the- (void) Applicationwillterminate: (UIApplication *) Application + { A the } + - //when the application receives a memory warning, it calls the $ //It is common to release unwanted memory in this method $- (void) Applicationdidreceivememorywarning: (UIApplication *) Application - { -NSLog (@"memorywarning"); the } - @end
Supporting Files--->uiapplication-prefix.pch file
#ifdef __objc__ #import <UIKit/UIKit.h> # Import <Foundation/Foundation.h>#endif
The complete process of program initiation
1 1. Main function2 3 2. Uiapplicationmain4*Create a UIApplication object5*Create a uiapplication delegate object6 7 3. Delegate object starts processing (listening) system events (no storyboard)8*when the program is started, the agent's application:didfinishlaunchingwithoptions is called: Method9*Create UIWindow in application:didfinishlaunchingwithoptions:Ten*Create and set Rootviewcontroller for UIWindow One*Display window A - 3to obtain the most important storyboard file name according to Info.plist, load the main storyboard (with storyboard) -*Create UIWindow the*Create and set Rootviewcontroller for UIWindow -* Display window
Application for iOS