AFNetworking的默认超时秒数?

Ari*_*ran 4 objective-c nsurl nsurlconnection ios afnetworking

在我的项目中,我使用AFNetworking进行Api调用,如何识别AFNetworking的默认超时秒数.请建议.

Anb*_*hik 15

为默认的超时AFNetwork60秒

超时间隔,以秒为单位.如果在连接尝试期间请求保持空闲的时间超过超时间隔,则认为该请求已超时.默认超时间隔为60秒.

额外的参考

如果你想减少超时

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
}];
Run Code Online (Sandbox Code Playgroud)