2.3应用程序启动UIApplicationMain
// 方法签名
/*
1.返回值为一个int类型
2.第一个参数:对应main函数的第一个参数:参数个数
3.第二个参数:对应main函数的第二个参数:参数列表
4.第三个参数:principalClassName UIApplication类或子类的类名字,如果为nil.默认为UIApplication
5.第四个参数:delegateClassName 应用程序代理类的名字
*/
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.
主要作用:在程序的入口点(程序的main方法)调用该方法,创建UIApplication对象和UIApplicationDelegate对象并且设置事件循环.
官方说明
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.
虽然这个方法指定了一个返回值,但是这个方法从来都不会返回.当用户按home键退出应用程序时,应用程序直接进入后台.
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.
这个方法从指定对应的参数创建应用程序对象和应用程序代理对象(如果有),并且将创建的应用程序代理对象设置为应用程序对象的代理.该方法还会开启主要的事件循环不包含应用程度额run loop.开始处理事件.加载info.plist文件到内存,如果info.plist文件中有配置对应的storyboard文件名,加载storyboard文件到内存.
网友评论