无法将类型“() -> Void”的值转换为预期的参数类型“(() -> Void)?”
Cannot convert value of type '() -> Void' to expected argument type '(() -> Void)?'
我在尝试转换为 Swift 3 时试图修复结局错误,但是我不确定为什么会收到错误
Cannot convert value of type '() -> Void' to expected argument type '(()
-> Void)?'
对于
CATransaction.setCompletionBlock(completion)
完整功能
fileprivate func deleteRowsAtIndexPaths(_ indexPaths: [IndexPath], withRowAnimation animation: UITableViewRowAnimation, duration: TimeInterval, completion:() -> Void) {
CATransaction.begin()
CATransaction.setCompletionBlock(completion) //Error
UIView.animate(withDuration: duration) { () -> Void in
self.deleteRows(at: indexPaths, with: animation)
}
CATransaction.commit()
}
有谁知道我为什么会收到这个错误以及如何解决该错误?
如果您在将代码迁移到 Swift 时发现异常,请检查 the latest reference 3.
Declaration
class func setCompletionBlock(_ block: (@escaping () -> Void)?)
尝试将方法的这一部分 header completion:() -> Void
更改为:
completion: @escaping () -> Void
我在尝试转换为 Swift 3 时试图修复结局错误,但是我不确定为什么会收到错误
Cannot convert value of type '() -> Void' to expected argument type '(() -> Void)?'
对于
CATransaction.setCompletionBlock(completion)
完整功能
fileprivate func deleteRowsAtIndexPaths(_ indexPaths: [IndexPath], withRowAnimation animation: UITableViewRowAnimation, duration: TimeInterval, completion:() -> Void) {
CATransaction.begin()
CATransaction.setCompletionBlock(completion) //Error
UIView.animate(withDuration: duration) { () -> Void in
self.deleteRows(at: indexPaths, with: animation)
}
CATransaction.commit()
}
有谁知道我为什么会收到这个错误以及如何解决该错误?
如果您在将代码迁移到 Swift 时发现异常,请检查 the latest reference 3.
Declaration
class func setCompletionBlock(_ block: (@escaping () -> Void)?)
尝试将方法的这一部分 header completion:() -> Void
更改为:
completion: @escaping () -> Void