2.3應(yīng)用程序啟動(dòng)UIApplicationMain
// 方法簽名
/*
1.返回值為一個(gè)int類型
2.第一個(gè)參數(shù):對(duì)應(yīng)main函數(shù)的第一個(gè)參數(shù):參數(shù)個(gè)數(shù)
3.第二個(gè)參數(shù):對(duì)應(yīng)main函數(shù)的第二個(gè)參數(shù):參數(shù)列表
4.第三個(gè)參數(shù):principalClassName UIApplication類或子類的類名字,如果為nil.默認(rèn)為UIApplication
5.第四個(gè)參數(shù):delegateClassName 應(yīng)用程序代理類的名字
*/
int UIApplicationMain ( int argc, char * _Nonnull argv[], NSString *principalClassName, NSString *delegateClassName );
Application Launch
UIApplicationMain This function is called in the main entry point to create the application object and the application delegate and set up the event cycle.
主要作用:在程序的入口點(diǎn)(程序的main方法)調(diào)用該方法,創(chuàng)建UIApplication對(duì)象和UIApplicationDelegate對(duì)象并且設(shè)置事件循環(huán).
官方說明
Return Value
Even though an integer return type is specified, this function never returns. When users exits an iOS application by pressing the Home button, the application moves to the background.
雖然這個(gè)方法指定了一個(gè)返回值,但是這個(gè)方法從來都不會(huì)返回.當(dāng)用戶按home鍵退出應(yīng)用程序時(shí),應(yīng)用程序直接進(jìn)入后臺(tái).
Discussion
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.
這個(gè)方法從指定對(duì)應(yīng)的參數(shù)創(chuàng)建應(yīng)用程序?qū)ο蠛蛻?yīng)用程序代理對(duì)象(如果有),并且將創(chuàng)建的應(yīng)用程序代理對(duì)象設(shè)置為應(yīng)用程序?qū)ο蟮拇?該方法還會(huì)開啟主要的事件循環(huán)不包含應(yīng)用程度額run loop.開始處理事件.加載info.plist文件到內(nèi)存,如果info.plist文件中有配置對(duì)應(yīng)的storyboard文件名,加載storyboard文件到內(nèi)存.