How to fix NSURLErrorDomain Error -999 in iPhone 3.0 OS

I am trying to update an application for iPhone with OS 3.0. I have a UIWebView that shows the page in order. But when I click the link, it raises my delegate for didFailLoadWithError, and the error is - the operation could not be completed. (Error NSURLErrorDomain -999.) I checked that this still works with OS 2.2.1, so it changed in 3.0.

Any ideas?

+49
Jun 21 '09 at 21:05
source share
3 answers

I managed to find the answer here .

This thread contains this description for this error: This error may occur if an another request is made before the previous request of WebView is completed...

I worked around this, ignoring this error and letting the webview continue to load.

 if ([error code] != NSURLErrorCancelled) { //show error alert, etc. } 
+113
Jun 27 '09 at 18:56
source share

NSURLErrorCancelled (-999)

"Returned when the asynchronous download is canceled. The Web Kit framework divider will receive this error when performing the undo operation on the boot resource. Note that the NSURLConnection or NSURLDownload delegate will not receive this error if the download is canceled."

For my situation (and probably yours) this can be ignored:

 if([error code] == NSURLErrorCancelled) return; // Ignore this error 
+28
Nov 10 '10 at 18:05
source share

The above TWO answers were CORRECT> Just return if the download request causes a cancellation.

I also want to note that people do NOT forget to put the NSLog in your didFailLoadWithError method, this can prevent you from wasting a lot of time finding the problem right on!

So, here is the final solution with everything I mentioned above:

 -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { NSLog(@"ERROR : %@",error); //Get informed of the error FIRST if([error code] == NSURLErrorCancelled) return; } 
+9
Apr 23 '13 at 11:32
source share



All Articles