Xcode 8 Warning “Instance method nearly matches optional requirement”

后端 未结 10 1518
情深已故
情深已故 2020-12-03 05:01

I converted my (macOS) project to Swift 3 in Xcode 8 and I get the following warnings with several delegate methods I implement in swift classes:

Instance me         


        
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 05:14

    For the record, I had the same problem when implementing WKWebView's didFailProvisionalNavigation delegate method. The solution was to add the @objc declaration and change the type of the last parameter from Error to NSError:

    @objc(webView:didFailProvisionalNavigation:withError:)
    func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError) {
        // handle error
    }
    

提交回复
热议问题