Which method and function is called first when any iOS application start ?
Which method and function is called first when any iOS application start?
5.6k views Asked by Milesh At
6
There are 6 answers
1
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
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.
0
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{}
I suppose its
in
main.m
fileBut for practical purposes I think you usually need to implement some of the UIApplicationDelegate's methods, depending on situation: