iOS program execution order and iOS program file execution order

Source: Internet
Author: User

Order of execution of iOS programs

First, start with the main function of the main.m file.
int main(int argc, char * argv[]){ @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }}//1、principalClassName:应用程序对象的类名(UIApplication或其子类)//2、delegateClassName:应用程序delegate的类名。(任何接受了UIApplicationDelegate的类)
Uiapplicationmain creates an application instance, an application proxy instance, based on the above two class names. Then establish the event loop (Runloop), detect various events of the program (the program starts, receives the touch, etc.)

A jump was made while executing the Uiapplicationmain function and was transferred to the AppDelete. Application proxy, which primarily detects the state of the application and makes appropriate processing. There are many applications in the state, such as: Program start, enter active state, go backstage, memory warning, receive remote message and so on. Any object that accepts the Uiapplicationdelegate protocol can become an application proxy. Once a state of the application is triggered, the appropriate proxy method is executed. Uiapplicationdelegate is an OC protocol. It declares a bunch of methods that are related to the running state of the application and are implemented by the application proxy. The UIApplication object is responsible for invocation.

Application:didfinishlaunchingwithoptions: Tell delegate that the program is starting to complete and that the program is ready to run. (When delegate implements this method, the Window object is created to present the program content to the user through window.) ), create the necessary interfaces for our application in this method, such as window
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];//初始化window self.window.backgroundColor = [UIColor grayColor];//设置window的背景色 [self.window makeKeyAndVisible];//把window设置为主视图 [self.window setRootViewController:[[UIViewController alloc] init]];//设置window的根视图控制器 return YES;}

Applicationwillresignactive: The program is about to end active, (for example: Suddenly call, SMS, down menu bar, etc.) will execute the method, generally in the method to do some necessary information storage, and some pause action. For example, to pause the game while the game is in progress
- (void)applicationWillResignActive:(UIApplication *)application { NSLog(@"*****%s",__func__);//__func__打印方法名}

Applicationdidenterbackground: The program has entered the background, if the program is in the background for a long time, it is possible to exit, so in this method to do some important data persistence. (Press the Home key)
- (void)applicationDidEnterBackground:(UIApplication *)application { NSLog(@"*****%s",__func__);}

Applicationwillenterforeground: The program will enter the foreground, the general type in the program from the background into the program when the implementation of this method
- (void)applicationWillEnterForeground:(UIApplication *)application { NSLog(@"*****%s",__func__);}

Applicationdidbecomeactive: Tells the delegate that the application has entered an active state (re-executing the suspended task), that the program starts or the background enters the foreground will execute the method
- (void)applicationDidBecomeActive:(UIApplication *)application { NSLog(@"*****%s",__func__);}

Applicationwillterminate: This method is executed when the exit is imminent
- (void)applicationWillTerminate:(UIApplication *)application{ NSLog(@"*****%s",__func__);}

iOS program file execution order in the plist file1.bundle Display name in the screen of the app's file name (deleted after change, rerun) 2.bundle Identifier on-line, uniquely identifies the 3.bundle version number 4. Supported Interface Orientations (Portrait (bottom home button)) 5.Icon files add different sizes of pictures 57*57/114*114 auto fillet 6.Icon Already includes gloss effects set Yes, remove highlight 7.Application doesn ' t run in background can be set to Yes . pch files, precompiled files infoplist. Strings file, about multilingual The frames are all header files .

iOS program execution order and iOS program file execution order

Related Article

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.