【发布时间】:2019-07-12 02:27:15
【问题描述】:
我只是想确认 UIAlertAction 的处理程序是一个非转义的 lambda 函数?
我做了 ctrl + 右键单击并查找了 UIAlertAction 定义,默认情况下它看起来没有转义。这意味着我应该这样做
weak var wself = self
并在所有 UIAlertAction 完成块中使用 wself 而不是 self?
在 UIKit>UIAlertController 下我看到了
open class UIAlertAction : NSObject, NSCopying {
public convenience init(title: String?, style: UIAlertAction.Style, handler: ((UIAlertAction) -> Void)? = nil)
处理程序不显示@escaping的地方
【问题讨论】:
-
它是一个转义闭包。我不知道为什么你不能从定义中看到它。也许是因为它来自 Objective-C。
-
可选的闭包都是隐式转义的。见here
-
感谢@sweeper。如果您想将此作为答案发布,我会接受。
标签: ios swift lambda uialertaction