![](/img/trans.png)
[英]Cannot convert value of type 'Void' to expected argument type '(String) -> Void'
[英]Cannot convert value of type '() -> Void' to expected argument type '(() -> Void)?'
我試圖修改我的壓軸錯誤,同時嘗試轉換為Swift 3,但我不確定為什么我得到錯誤
無法將類型'() - > Void'的值轉換為預期的參數類型'(( - - > 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 3時發現奇怪的內容時,請檢查最新的參考 。
宣言
class func setCompletionBlock(_ block: (@escaping () -> Void)?)
嘗試更改方法標題completion:() -> Void
這一部分completion:() -> Void
到此:
completion: @escaping () -> Void
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.