Cocoa – Handling timeouts in Webview

cocoawebkit

Suppose you have a webview that would load a page, how would you handle the situation if the page fails to load, for instance, in 20 seconds?

More specifically which WebView delegate method is called when the such situation occurs?

- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame

or

- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame

Best Answer

The distinction pointed out by Michael is important. In any case, if you register as a delegate for the UIWebView, you might end receiving the – webView:didFailLoadWithError: call. Here you can produce an UIAlertView with the error, or inject some pre-canned html or another view. It greatly depends on what you want to show.

Related Topic