我可以帮您进行翻译。以下是翻译的结果:
在Swift 4中不再是这种情况。 在解决了这个警告之后,一切都不像以前那样工作了。 现在有什么新的做法吗?
如果我将声明更新为:
我需要一个可按需执行的闭包方法。
在 Swift 3 中,我通常会这样做:
// Declare closure
var checksPerformed: ((Void) -> Void)? // Declaration
// Call when needed
checksPerformed?()
//Only executes when checksPerformed is called
checksPerformed = { _ in
// do stuff here
}
在Swift 4中不再是这种情况。 在解决了这个警告之后,一切都不像以前那样工作了。 现在有什么新的做法吗?
如果我将声明更新为:
var checksPerformed: (() -> ())?
,我会得到
var checksPerformed: (() -> Void)?
或var checksPerformed: (() -> ())?
两种方式都可以。个人而言,我避免使用Void
,而是在适当的情况下使用()
。 - oyalhichecksPerformed: (() -> ())?
// 声明 - Nazmul HasanVoid
。 - Sulthan