Why does modern Xcode generate projects with UIApplicationMain outside of autorelease pool?

214 views Asked by At

If I remember correctly, back in the days Xcode used to generate the main function something like this (at least for iOS applications):

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]);
    }        
}

I.e. UIApplicationMain function was wrapped inside of @autoreleasepool. However I noticed that currently Xcode no longer does that:

int main(int argc, char * argv[]) {
    NSString * appDelegateClassName;
    @autoreleasepool {
        // Setup code that might create autoreleased objects goes here.
        appDelegateClassName = NSStringFromClass([AppDelegate class]);
    }
    return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}

So, UIApplicationMain is outside of the autorelease pool by default nowadays. Is there any official changelog/paper that explains why the latter implementation is now preferred over the former one?

0

There are 0 answers