I want to inform user when HTTP error 404 etc is received. How can I detect that? I\'ve already tried to implement
- (void)webView:(UIWebView *)webView didFailL
Heres is my swift 3 version of @AxelGuilmin response:
func webViewDidFinishLoad(_ webView: UIWebView) {
guard let request = webView.request else { return }
let cachedUrlResponse = URLCache.shared.cachedResponse(for: request)
let httpUrlResponse = cachedUrlResponse?.response as? HTTPURLResponse
if let statusCode = httpUrlResponse?.statusCode {
if statusCode == 404 {
// Handling 404 response
}
}
}