Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Main function

Tags:

ios

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.

like image 264
Daisy Avatar asked Oct 19 '12 05:10

Daisy


1 Answers

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.

like image 97
Caleb Avatar answered Oct 13 '22 22:10

Caleb