jxx*_*jxx 32 macos cocoa cocoa-touch nsurlconnection ios
当我发送请求并收到错误代码错误时-1009,这意味着什么?我不知道如何处理它.
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(@"connection didFailWithError");
if(error.code==-1009){
//do something
}
}
Run Code Online (Sandbox Code Playgroud)
ric*_*ira 12
使用Swift,您可以使用NSURLErrorenum进行NSURL错误域检查:
switch NSURLError(rawValue: error.code) {
case .Some(.NotConnectedToInternet):
print("NotConnectedToInternet")
default: break
}
Run Code Online (Sandbox Code Playgroud)
斯威夫特3:
switch URLError.Code(rawValue: error.code) {
case .some(.notConnectedToInternet):
print("NotConnectedToInternet")
default: break
}
Run Code Online (Sandbox Code Playgroud)
斯威夫特4:
switch URLError.Code(rawValue: error.code) {
case .notConnectedToInternet:
print("NotConnectedToInternet")
default: break
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40918 次 |
| 最近记录: |