NSError NSURLError
NSError
NSError has information about error.
- domain
- code
- userinfo
NSError code List : Apple Developer
NSError by myself
errorWithDomain
NSError*err = [NSError errorWithDomain:@"TestDomain" code:400 userInfo:nil]; NSError*err2 = [NSError errorWithDomain:NSErrorDomain code:NSURLTimeOut userInfo:nil];
NSURLError UIWebView, WKWebView related
– (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error for UIWebView, – (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error, – (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
These delegate methods return NSError. We can detect error from this.
Foundation Constants Reference
These list are some of them
Error | Description |
---|---|
NSURLErrorNetworkConnectionLost | Returned when a client or server connection is severed in the middle of an in-progress load. Once succeeding connect, but disconnect |
NSURLErrorNotConnectedToInternet | Returned when a network resource was requested, but an internet connection is not established and cannot be established automatically, either through a lack of connectivity, or by the user’s choice not to make a network connection automatically |
NSURLErrorInternationalRoamingOff | International roaming off by the device |
NSURLErrorTimedOut | timeout before completion |
NSURLErrorUnknown | Unknown |
NSURLErrorBadURL | Returned when a URL is sufficiently malformed that a URL request cannot be initiated |
NSURLErrorUnsupportedURL | Returned when a properly formed URL cannot be handled by the framework |
etc…