Danie1s / Tiercel

简单易用、功能丰富的纯 Swift 下载框架
MIT License
2.67k stars 388 forks source link

Support for cell download in tableview #119

Closed tangzzz-fan closed 4 years ago

tangzzz-fan commented 4 years ago

Hi, Daniels, I used the tool in my test project for file download each file cell item, but Tiercel cannot give a good support about it, can you give a detail demo on it? The common scenario is a file list to download, click the cell download button to download the each file, observer the progress view in each cell. I tried the way: get tasks.safeObject in tableView:willDisplayCell, but, the order is missed. Thanks a lot

Danie1s commented 4 years ago

see the demo

image

tangzzz-fan commented 4 years ago

the demo used in ViewController2 need add download task first, then get task in session manager according of index path row. But in tableview cell download cases, all tasks have not been add to the session manager, getTask(indexpath.row) will return a wrong task.

Danie1s commented 4 years ago

I think I understand what you mean.

When you click the cell download button to add download task, the task comes last.

So, you have two ways to solve it:

  1. You can use url to get the right task
  2. Insert the task to the right index after add download task, by using this method : sessionManager.moveTask(at: sourceIndex, to: destinationIndex)
tangzzz-fan commented 4 years ago

Have solved the issue, thanks.