title: WKWebView catch HTTP error codes with Swift 4
body: <p>this question is identical to the following: <a href="https://stackoverflow.com/questions/32936168/wkwebview-catch-http-error-codes">WKWebView catch HTTP error codes</a>; unfortunately the methods in Obj-C are not applicable to Swift 4, thus the cited <code>WKNavigationResponse.response</code> is no longer of type <code>NSHTTPURLResponse</code> so it doesn't have the http status code.</p>
  
  <p>But the issue is still the same: I need to get the http status code of the answer to detect if the expected page is loaded or not.</p>
  
  <p>Please note that <code>webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error)</code> delegate is not called in case of <code>404</code> but only in case of network issue (i.e. server offline); the <code>func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)</code> is called instead.</p>
  
  <p>Thanks a lot for your answers.</p>