#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
}
return NSApplicationMain(argc, argv);
}
Why does a new Objective-C project's boilerplate contain an autorelease pool block, but a new Swift project doesn't?
Because the Swift project uses @main
, so there’s no main.swift
, so there’s no place where you can add initialisation code that would benefit from that autorelease pool.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
I found this to get some more details: https://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-swift-program