I am trying to fix my finale error whilst trying to convert to Swift 3, however I am unsure why I am getting the error
我试图修改我的压轴错误,同时尝试转换为Swift 3,但我不确定为什么我得到错误
Cannot convert value of type '() -> Void' to expected argument type '(() -> Void)?'
无法将类型'() - > Void'的值转换为预期的参数类型'(() - > Void)?'
For
CATransaction.setCompletionBlock(completion)
Complete Function
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()
}
Does anybody know why I am getting this and how I can resolve the error ?
有谁知道为什么我得到这个以及如何解决错误?
1 个解决方案
#1
6
Please check the latest reference when you find something odd in migrating your code to Swift 3.
当您将代码迁移到Swift 3时发现奇怪的内容时,请检查最新的参考。
Declaration
class func setCompletionBlock(_ block: (@escaping () -> Void)?)
Try changing this part of your method header completion:() -> Void
to this:
尝试更改方法标题完成的这一部分:() - > Void to this:
completion: @escaping () -> Void
#1
6
Please check the latest reference when you find something odd in migrating your code to Swift 3.
当您将代码迁移到Swift 3时发现奇怪的内容时,请检查最新的参考。
Declaration
class func setCompletionBlock(_ block: (@escaping () -> Void)?)
Try changing this part of your method header completion:() -> Void
to this:
尝试更改方法标题完成的这一部分:() - > Void to this:
completion: @escaping () -> Void