![](/img/trans.png)
[英]cannot convert value of type '()' to expected argument '() -> void'
[英]Cannot convert value of type '(_) -> ()' to expected argument type '(() -> Void)?'
我將代碼從Swift 2遷移到Swift 4,但是我不確定為什么會出現此錯誤:
無法將類型'(_)->()'的值轉換為預期的參數類型'(()-> Void)?
這是我的功能:
fileprivate func navigateToTagFriends(completion: @escaping (_ taggedUsers : [Athlete]?) -> Void) {
// Tag Users when item is original content
if self.parentContent == nil {
self.state = .finished // Mark as finished so friends operation will execute
if let tagController = UIStoryboard(type: .Capture).instantiateInitialViewController() as? TagViewController {
tagController.tagCompletionBlock = { taggedUsers in
self.presentingViewController?.dismiss(animated: true, completion: {_ in
if let processingView = Bundle.main.loadNibNamed("ProcessingView", owner: self, options: nil)?[0] as? UIView {
let size = self.presentingViewController?.view.frame.size
processingView.frame = CGRect(x: 0, y: 0, width: size?.width ?? 0, height: size?.height ?? 0)
self.processingView = processingView
self.presentingViewController?.view.addSubview(processingView)
}
completion(taggedUsers)
})
}
tagController.cancelBlock = {
self.presentingViewController?.dismiss(animated: true, completion: nil)
}
tagController.transitioningDelegate = self
self.presentingViewController?.present(tagController, animated: true, completion: nil)
}
} else {
completion(nil)
}
}
有人知道我為什么收到這個消息以及如何解決該錯誤嗎?
從行中刪除_ in
:
self.presentingViewController?.dismiss(animated: true, completion: {_ in
根據dismiss
文檔 , completion
回調不接受任何參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.