Craig Siemens
Craig Siemens

Reputation: 13296

Different NSError localizedDescription between iOS 7 and 8

I was testing how my app displays erros when not connected to the internet and I noticed that iOS 7 and 8 return different error messages for NSURLErrorNotConnectedToInternet (-1009)

iOS 7 Error

Error Domain=NSURLErrorDomain
Code=-1009 "The Internet connection appears to be offline."
UserInfo=0x17d5edc0 {NSLocalizedDescription=The Internet connection appears to be offline., 
                     NSUnderlyingError=0x17ecdd20 "The Internet connection appears to be offline."}

iOS 8 error

Error Domain=NSURLErrorDomain
Code=-1009 "The operation couldn’t be completed. (NSURLErrorDomain error -1009.)"
UserInfo=0x1740f9c80 {_kCFStreamErrorDomainKey=12,
                      _kCFStreamErrorCodeKey=8,
                      NSUnderlyingError=0x17405dd90 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1009.)"}

Is there any way to have iOS generate an error message that would be the same on both iOS 7 and 8?

Upvotes: 2

Views: 4322

Answers (3)

powtac
powtac

Reputation: 41080

You can use the error code mapping from http://nshipster.com/nserror/

Upvotes: 1

gnasher729
gnasher729

Reputation: 52622

Maybe the intent is that this is an error where you shouldn't just show an error message with the technical reason, but where you should think what it means in terms of the user. The Internet connection could be down because WiFi is turned off, or 3G data is turned off, so you could ask to turn it on depending on how important the data is. If you are doing some background update, you might just do nothing. Or you might suggest to the user to do the operation later if that makes sense.

Upvotes: 1

David Ansermot
David Ansermot

Reputation: 6112

Use the code, it's the same.

If they choosed to update the error message in iOS8, you can't do anything.

Upvotes: 1

Related Questions