Which method and function is called first when starting any iOS application?

Which method and function is called first when starting any iOS application?

+6
source share
6 answers

I believe him

int main(int argc, char *argv[])

in main.mfile

But for practical purposes, I think you usually need to implement some of the UIApplicationDelegate methods, depending on the situation:

application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillEnterForeground:
+7
source

If A View starts , then this:

- (void)viewDidLoad {}

If the application starts , this is:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:

or

- (void)applicationWillEnterForeground:(UIApplication *)application {

I think you better use the ViewDidLoad method .

I hope I helped!

+4
source

:

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
+2

, : didFinishLaunchingWithOptions: ..

DidLoad;

+1

apple doc

  • (BOOL) : ( UIApplication *) willFinishLaunchingWithOptions: (NSDictionary *) launchOptions {}

  • (BOOL): (UIApplication *) didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {}
0

,

int main(int argc, char *argv[])

,

application(_:willFinishLaunchingWithOptions:)

UIKit .

1) The app is launched, either explicitly by the user or implicitly by the system.

2) The Xcode-provided main function calls UIKit UIApplicationMain() function.

3) The UIApplicationMain() function creates the UIApplication object and your app delegate.

4) UIKit loads your app default interface from the main storyboard or nib file.

5) UIKit calls your app delegate application(_:willFinishLaunchingWithOptions:) method.

6) UIKit performs state restoration, which calls additional methods of your app delegate and view controllers.

7) UIKit calls your app delegate application(_:didFinishLaunchingWithOptions:) method.

The app launch and initialization sequence

Link - https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app/about_the_app_launch_sequence

0
source

All Articles