Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6105621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:59:27+00:00 2026-05-23T13:59:27+00:00

I was re-reading UIApplicationMain documentation and wondered, if UIApplicationMain never returns, why: is there

  • 0

I was re-reading UIApplicationMain documentation and wondered, if UIApplicationMain never returns, why:

  • is there a return at the end?
  • is there an NSAutoreleasePool?

I even ask myself: why int main(int argc, char *argv[]) on an iPhone?
Can we launch apps with a command line? What are argc and argv for? Are they used or just legacy C?

Some comments on Twitter from honorable fellows are that:

  • return is here for the compiler
  • the NSAutoreleasePool is useless.
  • the run loop needs an autorelease pool to be allocated (contradicts #2)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:59:27+00:00Added an answer on May 23, 2026 at 1:59 pm

    1) The return statement is probably just there because the compiler doesn’t know that the function can never return (it is not marked up in any special way, after all). So the compiler’s code flow analysis would warn that it had a missing return statement. That still doesn’t explain why UIApplicationMain() has a return value, though. Maybe there is an error situation where it actually can return, who knows.

    2) I think having an autorelease pool in main() around UIApplicationMain is wrong, as any object released without a pool will end up in this autorelease pool, which persists for the entire duration of the application. So effectively the object is still leaked.

    Usually, if there is no autorelease pool in place, the runtime logs an error message about the missing pool and tells the developer to set a breakpoint on _NSAutoreleaseNoPool to find where the pool-less autorelease happens. The top-level NSAutoreleasePool as found in the templates thus actually hides this leak from the users.

    UIApplicationMain() should build its own autorelease pool as needed (It has to create and tear down a pool once through the event loop anyway, otherwise objects would just add up in the outer pool, consuming all memory). If someone thinks they really need to run ObjC code before calling UIApplicationMain() (and they can’t do the same work in applicationDidFinishLaunching: or the likes), they can always create a pool before UIApplicationMain(). Since UIApplicationMain() is documented to never return (like exit()), there is no point in having commands following it anyway. The pool would never get released.

    If you look at the Mac templates, they actually do not have the pool.

    3) The parameters are used even if you double-click an application on the Mac. The OS passes certain information to the application that way. The first parameter is the path to the executable when it was launched, which is necessary to find files in the bundle, I presume. On the Mac, the PSN (process serial number) is also passed to an application as a parameter when launched from the Finder:

    05.07.11 22:18:54,129 [0x0-0x21e21e].com.thevoidsoftware.MacTestApp: 0: /Volumes/RamDisk/MacTestApp-fdcuwfrzopalmgaufwujijhqhvjc/Build/Products/Debug/MacTestApp.app/Contents/MacOS/MacTestApp
    05.07.11 22:18:54,129 [0x0-0x21e21e].com.thevoidsoftware.MacTestApp: 1: -psn_0_2220574
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading through the Flickr API documentation it keeps stating I require an API key
Reading through this question on multi-threaded javascript, I was wondering if there would be
Reading through the CKEditor documentation , I see that they have an option to
Reading the Python 3.2 tutorial here , towards the end one of the examples
Reading up on design patterns, and have found that there are 23(?) some-odd patterns
Reading the FTP RFC (RFC959), I notice some modes that I've never seen used,
Reading the documentation at http://jersey.java.net/nonav/documentation/latest/client-api.html#d4e704 makes me think that ClientFilter s are processed in
Reading through the documentation on Apache Tomcat, when I deploy a webapp it copies
Reading the bottom of the documentation, specifically: You can still retrieve properties of deleted
Reading clause 1.9/14 of the C++0x draft. There I find: Every value computation and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.