Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting point of ios application

if write something in

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

     NSLog(@"Starting point 1");
}

main.m

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

  NSLog(@"Starting point 0");
  }

Which one is more useful main.m or appDelegate.m one and in which scenerio.

like image 911
rohan k shah Avatar asked Feb 03 '14 15:02

rohan k shah


1 Answers

This is an interesting article that explains the app launch sequence.

http://oleb.net/blog/2011/06/app-launch-sequence-ios/

As a resume of the article the conclusion is:

Besides application:didFinishLaunchingWithOptions:, there are several more entry points for custom code during the launch sequence (none of which are usually needed):

Directly in main() before UIApplicationMain() is called. The init method of a custom UIApplication subclass. The initWithCoder: or awakeFromNib methods of our application delegate if it is created from a NIB file (the default). The +initialize methods of our application delegate class or a custom UIApplication subclass. Any class receives an +initialize message before it is sent its first message from within the program.

Note that this sequence only happens at the actual launch of an app. If the app is already running and simply brought back from the background, none of this occurs.

like image 108
Manuel Escrig Avatar answered Oct 14 '22 00:10

Manuel Escrig