2
나는 문제는 내가 진행되면서 각각에 대해 별도의 AFTHTTPClient
문제 - AFNetworking 큐
AFHTTPClient *requestHandler = [[AFHTTPClient alloc] initWithBaseURL:BASEURL];
[requestHandler enqueueBatchOfHTTPRequestOperations:operations progressBlock:^(NSUInteger numberOfCompletedOperations, NSUInteger totalNumberOfOperations) {
NSLog(@"%d completed on %d",numberOfCompletedOperations,totalNumberOfOperations);
} completionBlock:^(NSArray *operations) {
}];
에 AFNetwork 큐를
NSMutableArray *operations = [NSMutableArray array];
NSURLRequest *request1 = [NSURLRequest requestWithURL:URL1];
AFHTTPRequestOperation *operation1 = [[AFHTTPRequestOperation alloc] initWithRequest:request1];
operation1.outputStream = [NSOutputStream outputStreamToFileAtPath:PATH1 append:NO];
[operation1 setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
float progress = (float)totalBytesRead/totalBytesExpectedToRead;
NSLog(@"Progress 1 = %f",progress);
}];
[operations addObject:operation1];
NSURLRequest *request2 = [NSURLRequest requestWithURL:URL2];
AFHTTPRequestOperation *operation2 = [[AFHTTPRequestOperation alloc] initWithRequest:request2];
operation2.outputStream = [NSOutputStream outputStreamToFileAtPath:PATH2 append:NO];
[operation2 setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
float progress = (float)totalBytesRead/totalBytesExpectedToRead;
NSLog(@"Progress 2 = %f",progress*100);
}];
[operations addObject:operation2];
추가 요청을 사용하여 두 개의 요청을 다운로드하기위한 다음과 같은 코드를 얻을되어있다 의뢰. 그러나 두 가지 요청을 결합하여 전체적으로 진전이 필요합니다.
없음 그것은 잘못된 진전을 가져옵니다. 하지만 코드가 작동하도록 변경합니다. 두 개의 전역 변수를 추가하고 각 진행 상황을 저장하고 실제로 작동합니다. –