What does NSURLConnection's error code "-1009" mean?
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
.