iOS的app启动流程原理

APP的启动流程

  1. main文件
    #import <UIKit/UIKit.h>
    #import "AppDelegate.h"
    
    int main(int argc, char * argv[]) {
        @autoreleasepool {
            return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        }
    }

    这个方法会创建:application对象, application代理, 时间循环
    官方描述:

    Creates the application object and the application delegate and sets up the event cycle.
    This function instantiates the application object from the principal class and instantiates the delegate (if any) from the given class and sets the delegate for the application.
    It also sets up the main event loop, including the application’s run loop, and begins processing events. 
    If the application’s Info.plist file specifies a main nib file to be loaded, by including the NSMainNibFile key and a valid nib file name for the value, this function loads that nib file. 

    main函数的return即使有返回值, 它也不会执行
    Even though an integer return type is specified, this function never returns. When users exits an iOS app by pressing the Home button, the application moves to the background.

  2. 读取info.plist
    如果在info.plist设置了一个main nib将会被加载
     
  3. 加载控制器视图
    在AppDelegate文件中执行代理函数
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        return YES;
    }

     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值