我正在尝试从将同时运行的多个 NSURLSessionDataTasks 中聚合数据。
__block NSMutableDictionary *languageDetails = [NSMutableDictionary new];
[repos enumerateObjectsUsingBlock:^(NSDictionary *repoDict, NSUInteger idx, BOOL * _Nonnull stop) {
NSString *languageUrl = repoDict[@"languages_url"];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:languageUrl]
completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
// JSON Parse response
// Update languageDetails
}];
[task resume];
}];
如何使用在所有数据任务完成后调用的主回调或委托进行设置?