在Swift中等效于@autoreleasepool的东西是什么? [英] What is the equivalent of @autoreleasepool in Swift?

查看:112
本文介绍了在Swift中等效于@autoreleasepool的东西是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Swift中,我注意到没有@autoreleasepool{}构造,尽管Swift确实使用ARC.在Swift中管理自动释放池的正确方法是什么,或者由于某种原因将其删除了?

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 been removed for some reason?

推荐答案

WWDC 2014会议视频中对此有详细说明编号418使用乐器改进应用程序",您也可以将其下载为PDF.

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

这篇关于在Swift中等效于@autoreleasepool的东西是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆