What is the equivalent of @autoreleasepool in Swift?

五迷三道 提交于 2019-12-02 19:53:43

This is explained in detail in WWDC 2014 session video number 418 "Improving Your App with Instruments", which you can also download as a PDF.

But in short, the syntax is:

autoreleasepool {
  /* code */ 
}

Just FYI, Xcode constructed the full code as follows:

autoreleasepool({ () -> () in
    // code              
})

Guess the parentheses identifies the functions closure.

There is! It's just not really mentioned anywhere.

autoreleasepool {
    Do things....
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!