我有这样的代码来下载40 JSON超时发出过多AFNetworking当请求
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中不会发生。
有什么问题?
声音像连接太慢,服务器会引发超时错误。 – Tander