How to correctly implement didFailProvisionalNavigation using WKWebView?

I make a web browser and, like any other web browser, I would like to inform the user about an error that occurred while loading a web page.

I am currently showing localizedDescription errors in the didFailProvisionalNavigation method . It's all!

- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
    [self presentError:error.localizedDescription animated:YES];

    [_delegate webViewDidFailNavigation:self error:error];
}

The presentError method handles some non-issue user interface elements.

The method above works great for displaying common errors, such as:

  • Internet connection is disconnected.
  • Could not find the server with the specified host name.

But it also displays some unusual errors, such as:

  • Operation could not be completed (NSURL ErrorDomain error -999)

:

  • "NSURL", .
  • , , - , didFailProvisionalNavigation, .

, , , . , , , " ", , " ".

?

+4
1

webView(_:didFailProvisionalNavigation:withError:)

?

webView(_:didFail:withError:)

, , , .

0

Source: https://habr.com/ru/post/1681564/


All Articles