ios - AFNetworking 的默认超时秒数?

标签 ios objective-c afnetworking nsurlconnection nsurl

在我的项目中,我使用 AFNetworking 进行 Api 调用,如何确定 AFNetworking 的默认超时秒数。请提出建议。

最佳答案

AFNetwork 的默认超时为60 秒

The timeout interval, in seconds. If during a connection attempt the request remains idle for longer than the timeout interval, the request is considered to have timed out. The default timeout interval is 60 seconds.

附加 reference

如果你想减少超时

NSDictionary *params = @{@"par1": @"value1",
                     @"par2": @"value2"};

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager.requestSerializer setTimeoutInterval:25];  //Time out after 25 seconds

[manager POST:@"URL" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {

//Success call back bock
NSLog(@"Request completed with response: %@", responseObject);


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
 //Failure callback block. This block may be called due to time out or any other failure reason
}];

关于ios - AFNetworking 的默认超时秒数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32583052/

相关文章:

iPhone 方法原型(prototype)

ios - AFNetworking 缓存图像是自动加载还是我们必须手动加载?

objective-c - AFNetworking POST 请求向服务器发送空白参数

ios - AFNetworking 一次可以上传多少张图片

ios - Safari 检测视频何时播放完毕

objective-c - 直接分配和分配时,UIImageView/UILabel 属性始终为 nil

ios - 使用 Kingfisher 的 Swift iOS 照片采集会导致内存增长

ios - 在 uitableview 编辑模式下丢弃 segue

ios - 设置facebook graph checkins的坐标参数

ios - 使用 unarchivedObjectOfClass 复制 UIButton - 对象不能为零