iphone - AFDownloadRequestOperation multipleDownload progress for each download -


i using afdownloadrequestoperation downloading. unable track progress of each download in queue. progress bar show progress of operation on main thread(which last added request). referred many links not able track progress whole block. here's code

   (int =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 %@", 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 operation %@",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);       // progress view in section of tableview , updated reloading section shows same progress downloads.               [downloadtblview reloadsections:[nsindexset indexsetwithindex:1] withrowanimation:uitableviewrowanimationnone];          }];         //    [operation addobject:operation];         [operation start];     } 

i know getting same progress because of

 totalbytesreadforfile =  self.downloadcomplete;  totalbytesexpectedtoreadforfile = self.downloadsize; 

as set value progressview. out of ideas how track progress each process , display it. me please.

use afhttpclient -enqueuebatchofhttprequestoperations:progressblock:completionblock: track progress of operations within batch. each operation completed, can increment progress block reflect (e.g. "5 or 19 operations finished").

tracking cumulative byte accumulation operations unnecessary; aforementioned approach sufficiently communicates progress user.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -