iOS程式的完整啟動過程分析

來源:互聯網
上載者:User

標籤:style   class   blog   code   color   com   

 

1.點擊程式表徵圖,開啟程式

2.執行main函數,分析如下:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 int main(int argc, char * argv[]) {     @autoreleasepool {         /*          argc: 系統或者使用者傳入的參數個數          argv: 系統或者使用者傳入的實際參數          */         // return UIApplicationMain(argc, argv, nil, NSStringFromClass([NJAppDelegate class]));                   // return UIApplicationMain(argc, argv, @"UIApplication", NSStringFromClass([BLAppDelegate class]));                   /*          1.根據傳入的第三個參數建立UIApplication對象          2.根據傳入的第四個產生建立UIApplication對象的代理          3.設定剛剛建立出來的代理對象為UIApplication的代理          4.開啟一個事件迴圈          */          return <span style="color: rgb(255, 0, 0);">UIApplicationMain</span>(argc, argv, @"UIApplication", @"BLAppDelegate");  //3 、4 步驟     } }

 

3.執行UIApplicationMain函數

4.建立UIApplication對象、UIApplication的delegate對象

5.開啟事件迴圈監聽系統事件

 

6.程式載入完畢後調用delegate對象的application:didFinishLaunchingWithOptions:方法

1> 建立視窗對象

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

2> 建立控制器對象

self.viewController = [[BLViewController alloc] initWithNibName:@"BLViewController" bundle:nil];

3> 設定視窗的根控制器

self.window.rootViewController = self.viewController;

4> 讓視窗成為主視窗、並且可見

[self.window makeKeyAndVisible];

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.