WKWebView Delegate (decidePolicyFor) issues in Swift 3.0
<p>I am currently implementing a WKWebView into my application and I want to use the decidePolicyFor delegation method to decide how my app responds to external links.</p>

<pre><code>    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -&gt; Void) {


    if navigationAction.navigationType == WKNavigationType.linkActivated &amp;&amp; !(navigationAction.request.url?.host?.lowercased().hasPrefix("www.example.com"))! {
        UIApplication.shared.open(navigationAction.request.url!, options: [:], completionHandler:nil)
        decisionHandler(.allow)

    }
    else
    {
        decisionHandler(.cancel)
    }


}
</code></pre>

<p>However the compiler is giving me the following issue in swift 3.0 :-</p>

<blockquote>
  <p>Instance method 'webView(<em>:decidePolicyFor:decisionHandler:)' nearly matches optional requirement 'webView(</em>:decidePolicyFor:decisionHandler:)' of protocol 'WKNavigationDelegate'</p>
</blockquote>

<p>Does anybody know the solution to this and more importantly why this is happening</p>

<p>Thanks in advance </p>