return UIApplicationMain(argc, argv, nil,NSStringFromClass([AppDelegate class]));
//This function is called in the main entry point to create the application object and the application delegate and set up the event cycle.
/**
* 函数在主入口点来创建应用程序对象、应用程序代理和创建事件循环
argc
The count of arguments in argv; this usually is the corresponding parameter to main.
// 参数列表中参数的个数;这通常是main相应的参数
argv
A variable list of arguments; this usually is the corresponding parameter to main.
// 一个可变的参数列表;这通常是main相应的参数。
principalClassName
The name of the UIApplication class or subclass. If you specify nil, UIApplication is assumed.
// 主要的类名 -> UIApplication类或者其子类的名字,如果你指定为空,则默认为UIApplication
delegateClassName
The name of the class from which the application delegate is instantiated. If principalClassName designates a subclass of UIApplication, you may designate the subclass as the delegate; the subclass instance receives the application-delegate messages. Specify nil if you load the delegate object from your application’s main nib file.
// delegateClassName是应用程序类的代理类。如果主要nib文件(在info.plist文件中指定,key是NSMainNibFile)存在,就会在nib文件对象里寻找Application对象和连接它的delegate,因为UIApplication定义了一个delegte变量,这个变量应该遵循UIApplicationDelegate,负责控制程序的运行,如果主nib文件没有这个类,你应该自定义一个这样的类,并将第四个参数改为这个类的类名,UIApplicationMain
最新推荐文章于 2026-04-16 10:02:40 发布
本文深入解析了iOS应用启动过程中调用的UIApplicationMain函数的作用与工作原理,详细阐述了argc、argv、principalClassName、delegateClassName等参数的意义及应用场景。通过解读这些关键概念,读者能够更清晰地理解iOS应用从启动到运行的完整流程。

199

被折叠的 条评论
为什么被折叠?



