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

6

7

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

Mukul answered 18/2, 2011 at 10:6 Comment(0)
L
9

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:
Lancers answered 18/2, 2011 at 10:7 Comment(1)
main is a function, not a method. This isn't Ruby.Strobila
B
4

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!

Blacktail answered 18/2, 2011 at 10:49 Comment(1)
your answer was really helpful. Thanks.Mukul
M
4

actually:

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

comes before:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
Malapropism answered 10/2, 2014 at 17:13 Comment(0)
J
2

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

Josephjosepha answered 21/9, 2019 at 14:37 Comment(0)
S
1

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

After when view is launched

at that time viewDidLoad is executed;

Simba answered 3/4, 2012 at 6:4 Comment(0)
S
1

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{}
Semiquaver answered 25/3, 2016 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.