2

I have a UIWebView in my iPhone application where I am loading the website. Basically I am opening the mobile website in app. In website, there is media upload functionality/ When user tries to upload photo(within mobile site), I am facing error is :-

NSURLErrorDomain error -999

The same web view(code) works fine with other URLs like www.apple.com and www.google.com.

NSURLRequest *request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:self.urlToLoad]];
        [webview loadRequest:request];

It doesnt seem to be a redirect issue. How to fix the error?

I am also getting the below warnings.

WF: _userSettingsForUser mobile: { filterBlacklist = ( ); filterWhitelist = ( ); restrictWeb = 1; useContentFilter = 0; useContentFilterOverrides = 0; whitelistEnabled = 0; }

Related error link:- https://discussions.apple.com/thread/1727260?start=0&tstart=0

pkc456
  • 8,350
  • 38
  • 53
  • 109
  • see this https://stackoverflow.com/questions/39793459/xcode-8-ios-10-starting-webfilter-logging-for-process disable `OS_ACTIVITY_MODE = disable` – Dhiru Jun 30 '17 at 11:09
  • @Dhiru, By disabling the activity mode, only console warnings will omit only. Actual issue is `NSURLErrorDomain error 999` while uploading photo in `UIWebView` – pkc456 Jun 30 '17 at 11:24

1 Answers1

2

This one is for WKWebView and Swift.

-999 is caused by ErrorCancelled. This means: another request is made before the previous request is completed. You can check it in this answer

In my scenario, I am checking the error code, if it is -999 then I just return from a function like following

  func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {

   if error.code == NSURLErrorCancelled {
        return
    }

   //*** Your functionality ***
}

Note: Unlike NSError of Objective-C, 'code' property is not available with Swift Error. You handle it by creating enum as in this answer.

Chetan Koli
  • 178
  • 15