1

我对 Swift 比较陌生,并且收到了Multiple Closures with Trailing Closure Violation:...来自 SwiftLint 的警告。导致这种情况的我的代码如下所示:

self.start(loggedIn: { _, error in
    //...
// below line causes warning
}) { [weak self] (someInfo: SomeInfo?, error: ErrorType) in
    //...
}
4

1 回答 1

1

此评论详细说明了如何通过示例进行此操作:

UIView.animate(withDuration: 1.0, animations: {
    self.view.alpha = 0.0
}, completion: { _ in
    self.view.removeFromSuperview()
})

所以在这种情况下,它将是:

self.start(loggedIn: { _, error in
    //...
}, started: { [weak self] (_: SomeInfo?, error: ErrorType) in
    //...
})
于 2020-03-17T05:32:57.230 回答