简体   繁体   English

urlsession,如何获得多个文件下载的整体进度

[英]urlsession, how would you get the overall progress on multiple files download

Using a URLSessionDownloadTask. 使用URLSessionDownloadTask。 Is there any way to get the overall progress of a multiple files download using the delegate didwritedata? 有什么办法可以使用委托didwritedata获得多个文件下载的整体进度? in a 在一个

I have the expected size of all files, now I need the totalbyteswritten for all current tasks and then all future tasks would be added to this "pool"..right now by default the totalbyteswritten are by task. 我具有所有文件的预期大小,现在我需要为所有当前任务写入totalbytes,然后将所有将来的任务添加到此“池” ..现在默认情况下,写入的totalbytes由任务组成。

Using the task identifier maybe? 也许使用任务标识符?

I'm assuming you're using a URLSessionDownloadTask . 我假设您正在使用URLSessionDownloadTask You should add that to your question. 您应该将其添加到您的问题中。

If you have multiple download tasks running you should save them to a collection of some sort. 如果有多个下载任务在运行,则应将它们保存到某种形式的集合中。 A dictionary would work well. 字典会很好用。 You will need to sum the total bytes written for each task into a total yourself. 您将需要自己将为每个任务写入的总字节求和。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM