Resuming data is always zero when calling cancelByProducingResumeData:

I am trying to access the resumeDatadownload file when the application is completed. I tried calling the method from willEnterBackgroundand willTerminateto appDelegate.

I can access the value resumeDatafrom the view class, but the problem is that when this method is called, it downloadSessioncloses automatically.

+4
source share
1 answer

When called, cancelByResumingData:it will create resumeData, and right after that it will call URLSessionTask-didCompleteWithError. There we set a flag to detect where the application is paused or not, and we can save resumeDatawithout canceling the download.

, :

self.downloadTask = [self.session downloadTaskWithResumeData: objFile.resumeData];
[self.downloadTask resume];

// Here objFile is an object stored in core data
+1

Source: https://habr.com/ru/post/1537504/


All Articles