Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

NSURLErrorDomain error -999

I am using UIWebView to render a GPS map on the iPhone. When I load it with the following code:

[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[textField text]]]];

I get an NSURLErrorDomain error -999. The same code works fine with other URLs like www.apple.com and www.intel.com. It doesnt seem to be a redirect issue; I tested it by creating a tinyurl for www.apple.com and it worked fine with my code. Where would I find the documentation for error code -999 or how to fix the error?

Mac OS X (10.5.4)

Posted on Sep 25, 2008 10:18 AM

Reply
4 replies

Jan 26, 2009 6:35 AM in response to JavaJini

<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
}


I'm still not sure what causes the error, but it might have something to do with iFrames or JavaScript requests. It's definitely not a redirect issue.

Mar 24, 2009 3:00 AM in response to Pumbaa

Like JavaJini, I put a similar code in the IBAction of a button.

-(IBAction)goButtonIsTouched:(id)sender {
[theWebView stopLoading];
NSURLRequest *URLReq = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]];
[theWebView loadRequest:URLReq];
[theWebView reload];
}

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).

Mar 24, 2009 3:35 AM in response to JavaJini

NSURLErrorDomain error -999 == NSURLErrorCancelled.

The explanation:
"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.

NSURLErrorDomain error -999

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.