Which method and function is called first when any iOS application start ?
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:
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!
actually:
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
comes before:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
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.
when application launches, first of all application:didFinishLaunchingWithOptions: method is called..
After when view is launched
at that time viewDidLoad is executed;
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{}
© 2022 - 2024 — McMap. All rights reserved.