ErrorCode
if (error.code ==NSURLErrorTimedOut) {
[OMGToastshowWithText:@"当前网络不佳,请稍后重试"];
}elseif (error.code ==NSURLErrorNotConnectedToInternet)
{
[OMGToastshowWithText:@"网络未连接,请检查网络"];
}
elseif (error.code ==NSURLErrorCannotConnectToHost)
{
[OMGToastshowWithText:@"服务器开小差了。。"];
}
elseif (error.code ==NSURLErrorBadServerResponse)
{
[OMGToastshowWithText:@"服务器错误"];
}
else
{
[OMGToastshowWithText:@"连接错误"];
}
未知错误
NSURLErrorUnknown = -1,
网络未连接,请检查网络
NSURLErrorCannotConnectToHost = -1004,
NSURLErrorCannotFindHost = -1003,
NSURLErrorNotConnectedToInternet = -1009,
当前网络不佳,请稍后重试
NSURLErrorTimedOut = -1001
NSURLErrorCannotLoadFromNetwork = -2000,
请求失败,请重试
NSURLErrorCancelled = -999
服务器错误
NSURLErrorBadServerResponse = -1011,
NSURLErrorResourceUnavailable = -1008,
服务器返回异常
NSURLErrorServerCertificateHasBadDate = -1201,
NSURLErrorCannotDecodeRawData = -1015,
NSURLErrorCannotDecodeContentData = -1016,
失去连接,请重试
NSURLErrorNetworkConnectionLost = -1005,
下载失败
NSURLErrorDownloadDecodingFailedMidStream = -3006,
NSURLErrorDownloadDecodingFailedToComplete = -3007
非法url
NSURLErrorBadURL = -1000,
NSURLErrorUnsupportedURL = -1002,