【问题标题】:UIAlertAction handler is non escaping? [duplicate]UIAlertAction 处理程序没有转义? [复制]
【发布时间】: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


【解决方案1】:

UIAlertAction 处理程序正在转义

因为可选闭包都是隐式转义的(感谢@sweeper)

【讨论】:

    猜你喜欢
    • 2014-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多