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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With