When I send a request and get an error with the error code -1009
, what does that mean? I'm not sure how to handle it.
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(@"connection didFailWithError");
if(error.code==-1009){
//do something
}
}
If you experience the error code 1009, it typically points to information stored on your device that needs to be refreshed.
A requested resource couldn't be retrieved. An attempt to establish a secure connection failed for reasons that can't be expressed more specifically. A server certificate is expired, or is not yet valid. A server certificate wasn't signed by any root server.
You might see this error message if you are running an outdated version of the NetUpdate application on your Mac. To resolve the issue, simply download and install the latest version of NetUpdate. Now, restart your computer and NetUpdate should work again as expected.
Since the error returned should be within the NSURLErrorDomain
, the code -1009
means:
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.
With Swift, you can use the NSURLError
enum for NSURL error domain check:
switch NSURLError(rawValue: error.code) {
case .Some(.NotConnectedToInternet):
print("NotConnectedToInternet")
default: break
}
Swift 3:
switch URLError.Code(rawValue: error.code) {
case .some(.notConnectedToInternet):
print("NotConnectedToInternet")
default: break
}
Swift 4:
switch URLError.Code(rawValue: error.code) {
case .notConnectedToInternet:
print("NotConnectedToInternet")
default: break
}
It's NSURLErrorNotConnectedToInternet
which means, well, that you're not connected to the internet... :)
You can find the error codes in NSURLError.h
.
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