ダウンロードに使用AFDownloadRequestOperation
しています。キューにある各ダウンロードの進行状況を追跡できません。私の進行状況バーは、メイン スレッド (最後に追加された要求) での操作の進行状況を示します。多くのリンクを参照しましたが、ブロック全体の進行状況を追跡できませんでした。これがコードです
for (int i =0; i<count; i++)
{
VideoClass *item1=[[VideoClass alloc]initWithVideo:[self.Downloads objectAtIndex:i]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:item1.URL]];
NSString *videoTgtPath = [[[[VideoDBClass alloc] init] autorelease] getPathToVideoFile:[self.Downloads objectAtIndex:i]];
AFDownloadRequestOperation *operation = [[AFDownloadRequestOperation alloc] initWithRequest:request targetPath:videoTgtPath shouldResume:YES];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Successfully downloaded file to %@", videoTgtPath);
if ([[[[VideoDBClass alloc] init] autorelease] completeDownload:item1 error:nil])
{
NSLog(@"Successfully Moved ");
}
self.AllDownLoads = [[[[VideoDBClass alloc] init] autorelease] getVideos];
[DownloadTblView reloadData];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"Error: %@", error);
}];
[operation setProgressiveDownloadProgressBlock:^(AFDownloadRequestOperation *operation1,NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpected, long long totalBytesReadForFile, long long totalBytesExpectedToReadForFile)
{
totalBytesReadForFile = self.DownloadComplete;
totalBytesExpectedToReadForFile = self.DownloadSize;
NSLog(@"the name of the operation is %@",operation1.request.URL.absoluteString);
NSLog(@"Operation%i: bytesRead: %d", 1, bytesRead);
NSLog(@"Operation%i: totalBytesRead: %lld", 1, totalBytesRead);
NSLog(@"Operation%i: totalBytesExpected: %lld", 1, totalBytesExpected);
NSLog(@"Operation%i: totalBytesReadForFile: %lld", 1, totalBytesReadForFile);
NSLog(@"Operation%i: totalBytesExpectedToReadForFile: %lld", 1, totalBytesExpectedToReadForFile);
// My PROGRESS View in the this section of the tableview and get updated by reloading this section But it shows the same progress for all downloads.
[DownloadTblView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
}];
// [operation addObject:operation];
[operation start];
}
私は同じ進歩を得ていることを知っています
totalBytesReadForFile = self.DownloadComplete;
totalBytesExpectedToReadForFile = self.DownloadSize;
彼らが私のprogressViewの値を設定したとき。しかし、各プロセスの進捗状況を追跡して表示する方法がわかりません。お願い助けて。