37957 Views 4 Replies Latest reply: Mar 24, 2009 3:35 AM by Jminijmini
<conjecture> Error -999 can be safely ignored in a UIWebView</conjecture>
This is a dirty workaround that makes UIWebView work as it should
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
NSLog(@"Error %i", error.code);
if (error.code == NSURLErrorCancelled) return; // this is Error -999
// error handling for "real" errors here
Like JavaJini, I put a similar code in the IBAction of a button.
NSURLRequest *URLReq = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]];
The first time a click on the button, it is working fine, and the second time it is not.
Maybe something has to be done before calling loadRequest a second time.
The workaround proposed by Pumbaa do not display the error, but the page is still not reloading (the error still happend).
NSURLErrorDomain error -999 == NSURLErrorCancelled.
"Returned when an asynchronous load is canceled. A Web Kit framework
delegate will receive this error when it performs a cancel operation on a
loading resource. Note that an NSURLConnection or NSURLDownload delegate
will not receive this error if the download is canceled."
So the conjecture from pumba is correct, you do not need to display it.
The code I have given before trigger a such Error because I did a loadRequest and a reload (the reload line is not necessary).
--> making a stopLoading before the new request is a good idea.
A other way to trigger such errors is to click very quickly on 2 links. The first request is canceled (--> Trigger the -999 error).
If you want to avoid such error, you can add some overhead code in order to assure that when something is loading nothing else can be loaded. But as pumba said it is not a big deal.