What is the equivalent of @autoreleasepool in Swift?

前端 未结 4 1491
抹茶落季
抹茶落季 2021-02-01 11:35

In Swift, I notice there is no @autoreleasepool{} construct, although Swift does use ARC. What is the proper way to manage an autoreleasepool in Swift, or has it be

4条回答
  •  悲哀的现实
    2021-02-01 12:23

    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 */ 
    }
    

提交回复
热议问题