Benches iPhone

4

NSURLErrorDomain error -999

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

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 http://www.apple.com and http://www.intel.com. It doesnt seem to be a redirect issue; I tested it by creating a tinyurl for http://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?

4 replies

Sign in or join Beachball Help to reply.

  1. 0

    Pumbaa

    Imported from the Apple Support Forums via the Wayback Machine 🔗

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

  2. 0

    noam_dev

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I get the same error occasionally within WebViews and I have no idea why this is occurring.

  3. 0

    Jminijmini

    Imported from the Apple Support Forums via the Wayback Machine 🔗

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

  4. 0

    Jminijmini

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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.