ios - Issue with NSURLSession with multiple downloads in background with multiple sessions and multiple segments -


we have crated session below configuration code. call method each task crate.

+(nsurlsession ) getnewsessionwithid:(nsstring )sessionid delegateobject:(id)sender  {     nsurlsession *session;     nsurlsessionconfiguration *configuration = [nsurlsessionconfiguration backgroundsessionconfigurationwithidentifier:sessionid];     nsoperationqueue *queue=[[nsoperationqueue alloc]init];     queue.maxconcurrentoperationcount=10;     queue.name=sessionid;      session = [nsurlsession sessionwithconfiguration:configuration delegate:sender delegatequeue:queue];      nslog(@"session id :%@",session);     nslog(@"queue : %@",queue);    return session; } 

even multiple sessions created multiple tasks 1 session active , 1 task executing , task 3 part downloading 1 session.

this method called create , start download task.

-(void)dlrequestallrenge:(nsmutablearray*)arrayrange andfileinfo:(fileinfo *)fileinfoobj {     nsmutablearray *arrayallparts=[[nsmutablearray alloc]init];     fileinfoobj.temppath=[fileinfoobj uniquefilename:[nstemporarydirectory() stringbyappendingstring:[fileinfoobj.name stringbydeletingpathextension]]];     [self createtempdirectory:fileinfoobj.temppath];     nslog(@"req session:%@",fileinfoobj.session);     (int i=0; i<arrayrange.count; i++)     {         nsstring *rangstring = [arrayrange objectatindex:i];         nsmutableurlrequest *request=[[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring:fileinfoobj.url]];         [request setvalue:rangstring forhttpheaderfield:@"range"];          nsstring *filename=[nsstring stringwithformat:@"%@(%d).data",[fileinfoobj.name stringbydeletingpathextension],i];         nsstring *filepath=[fileinfoobj.temppath stringbyappendingpathcomponent:filename];         fileinfo *subfileinfo=[[fileinfo alloc]init];         subfileinfo.url=fileinfoobj.url;         subfileinfo.name=filename;         subfileinfo.path=filepath;         subfileinfo.folder=[fileinfoobj getcurrentfoldername:filepath];         subfileinfo.range=rangstring;         subfileinfo.isdownloaded=no;         subfileinfo.nsurlsessionid=fileinfoobj.nsurlsessionid;         subfileinfo.progress=@"0";         subfileinfo.priority=[nsstring stringwithformat:@"%d",i];         subfileinfo.filedetail=@"connecting...";         subfileinfo.filestatus=requeststatusdownloading;         subfileinfo.request=request;         subfileinfo.starttime=[nsdate date];         nsurlsessiondownloadtask *downloadtask = [fileinfoobj.session downloadtaskwithrequest:request];         downloadtask.taskdescription=filepath;         [downloadtask resume];         subfileinfo.downloadtask=downloadtask;         [arrayallparts addobject:subfileinfo];      }     fileinfoobj.parts=arrayallparts;      [downloadingarray addobject:fileinfoobj];      [bgdownloadtableview reloaddata];  } 

issue 1 why sessions not active?

issue 2 why 3 part 1 task , 1 session downloading?

is there way can activate more session download more part concurrently?

please me this. appreciated.

update

we able download data using above code issue not able downloaded data when downloading task stopped using -suspend or -cancel.

is there way able retrieve raw data not resumedata original downloaded data?


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -