我的项目正在使用AFNetworking。
https://github.com/AFNetworking/AFNetworking
如何降低超时时间?没有互联网连接的自动取款机故障模块大约2分钟内不会被触发。Waay to long....
发布于 2013-03-14 04:19:19
基于其他人的回答和@mattt对相关项目问题的建议,如果你是AFHTTPClient
的子类化,这里是一个快速的插件
@implementation SomeAPIClient // subclass of AFHTTPClient
// ...
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method path:(NSString *)path parameters:(NSDictionary *)parameters {
NSMutableURLRequest *request = [super requestWithMethod:method path:path parameters:parameters];
[request setTimeoutInterval:120];
return request;
}
- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method path:(NSString *)path parameters:(NSDictionary *)parameters constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block {
NSMutableURLRequest *request = [super requestWithMethod:method path:path parameters:parameters];
[request setTimeoutInterval:120];
return request;
}
@end
经测试可在iOS 6上运行。
https://stackoverflow.com/questions/8304560
复制相似问题