iOS: Main function

ios

Solution

`main()` is the main entry point for any C, C++, or Objective-C program. It's basically called by the operating system to start the program. (That's not quite true -- it's a little more complicated than that, but it's not a bad mental model.) in fact, `main` doesn't just start the program -- it is the program. The program ends when execution reaches the end of `main`.

Problem

Could someone give some explanation what is the main function exactly does in iOS app? and who is calling this function and inputting the right parameter? ``` #import "AppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } ``` Thanks.

Original source