The complete process for program startup:
( 1 ) Main function
( 2 ) Uiapplicationmain
* Create UIApplication objects
* Create a UIApplication delegate object
( 3 ) Delegate object starts processing ( listening ) System Events ( no Storyboard)
* When the program is started, the agent's application:didfinishlaunchingwithoptions is called: method
* Create UIWindow in application:didfinishlaunchingwithoptions:
* Create and set UIWindow Rootviewcontroller
* Display window
( 3 ) According to Info.plist get the most important Storyboard the file name , load the most important Storyboard ( with Storyboard)
* Create UIWindow
* Create and set UIWindow Rootviewcontroller
* Display window
( 4 ) Uiapplicationmain
A uiapplicationmain function is executed in the main function:
int uiapplicationmain (int argc, char *argv[], NSString
*principalclassname, NSString *delegateclassname);
The meaning of each parameter:
argc , argv: Transfer directly to Uiapplicationmain for related processing.
principalclassname: Specifies the application class name (symbol of the app), which must be uiapplication (or subclass). If nil, the UIApplication class is used as the default value.
delegateclassname: Specifies the application's proxy class, which must adhere to the Uiapplicationdelegate protocol.
The Uiapplicationmain function creates a UIApplication object based on Principalclassname and creates a delegate object from Delegateclassname. and assigns the delegate object to the delegate property in the UIApplication object.
The application's main Runloop (event loop) is then created, and the event is processed (the application:didfinishlaunchingwithoptions of the delegate object is called first after the program is finished).
The Uiapplicationmain function returns when the program exits normally.
iOS-developed iOS program startup process