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

5.6k views Asked by At

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

6

There are 6 answers

1
Vladimir On BEST ANSWER

I suppose its

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

in main.m file

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

application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillEnterForeground:
1
JJgendarme On

If A View starts up, then it's:

- (void)viewDidLoad {}

If an app starts up it's:

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

or

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

I think you'l be better of using the ViewDidLoad Method.

I hope i helped!

0
iCoder On

when application launches, first of all application:didFinishLaunchingWithOptions: method is called..

After when view is launched

at that time viewDidLoad is executed;

0
Pedroinpeace On

actually:

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

comes before:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
0
DevesH On

First function called during app launch

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

First method called during app launch

application(_:willFinishLaunchingWithOptions:)

UIKit handle most of app launch tasks.

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

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

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

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

5) UIKit calls your app delegate's 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's application(_:didFinishLaunchingWithOptions:) method.

The app launch and initialization sequence

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

0
Prasad Bulbule On

Have look at image According to apple doc

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

gets called before

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