簡體   English   中英

無法將類型'(_)->()'的值轉換為預期的參數類型'(()-> 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM