我有這樣的代碼來下載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