【发布时间】:2014-03-24 18:06:18
【问题描述】:
我有这个代码可以下载 40 json
NSMutableArray *mutableOperations = [NSMutableArray array];
for (NSDictionary *dict in general_URL) {
NSURL *url = [dict objectForKey:@"url"];
NSString *key = [dict objectForKey:@"key"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.all_data setObject:[self parseJSONfile:responseObject] forKey:key];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[mutableOperations addObject:operation];
}
NSArray *operations = [AFURLConnectionOperation batchOfRequestOperations:mutableOperations progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) {
NSLog(@"progress:%f", (float)numberOfFinishedOperations / totalNumberOfOperations);
} completionBlock:^(NSArray *operations) {
NSLog (@"all done");
}];
[manager.operationQueue addOperations:operations waitUntilFinished:NO];
如您所见,我使用管理器来处理请求队列。问题是突然间,它以 -1001 代码超时。 它仅在 EDGE 模式下发生,在 wifi 和 3g 下不会发生。
有什么问题?
【问题讨论】:
-
好像连接太慢,服务器抛出超时错误。
标签: ios objective-c json afnetworking-2