0
int main(int argc, char *argv[])
{
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   int retVal = UIApplicationMain(argc, argv, nil, nil);
   [pool release];
   return retVal;
}
  1. will UIApplicationMain() call will return only after completion of our application execution? because i have next line [pool release]

  2. how can i pass the command line argument in main()?

  3. What are the possible int value that UIApplicationMain() will return and their state?

Rooban Ponraj A
  • 281
  • 4
  • 20

1 Answers1

2

will UIApplicationMain() call will return only after completion of our application execution? because i have next line [pool release]

UIApplicationMain() will never return. The [pool release] and return are just for aesthetic balance.

how can i pass the command line argument in main()?

The command line arguments are already there in argv. You can do what you like with them prior to UIApplicationMain(). If you mean "how do I access them outside of main()," see NSProcessInfo. This is generally not very useful in iOS.

What are the possible int value that UIApplicationMain() will return and their state?

There are none. See the UIKit Function Reference.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • if UIApplicationMain() will never return, then why we are assigning the UIApplicationMain() function call to int variable? – Rooban Ponraj A Apr 06 '13 at 02:36
  • 1
    Probably for historic reasons. Or perhaps there is a private API that makes it return, and Apple wants the template to work for their own apps that use the private API. Also, the `[pool release]` is required to prevent the static analyzer from complaining. – rob mayoff Apr 06 '13 at 02:40