Why did the <main> cocoa pattern relate to the main function?

With the dawn of ARC, a new main function template has appeared in xcode, which makes more sense. However, I have a question about the old template.

As you know, the old main function template in Xcode applications for Cocoa touch was as follows:

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

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}

However, the last two lines are not available, as the docs clearly indicate that the UIApplicationMain never returns. It just makes a call to exit () when this is done. Why did Apple choose such a template? Why not just that?

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

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    return UIApplicationMain(argc, argv, nil, nil);
}

Is it because people will take this as an example and not release their abstract pools correctly? Or because it will disable the static analyzer? Or is something else possible?

, -. , Apple?

+3
1

, , Unused variable, , .

+1

All Articles