NSFileProviderExtension extension show download Progress

安稳与你 提交于 2019-12-11 08:38:53

问题


I have implemented FileProvider Extension.

class MyProviderExtension: NSFileProviderExtension {

    override func startProvidingItem(at url: URL, completionHandler: ((_ error: Error?) -> Void)?) {
            downloading file using URL and implemented download delegates

// Download Delegate
    func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {

**// How can I upload the download progress here.**
}

   }
}

I am not able to get any UI handler in download delegates to update the progress and update the cell download button after successful download.


回答1:


To support progress display on download/upload progress, you need to do:

  1. Use NSURLSessionTask to download/upload files
  2. Use NSURLSession with backgroundSession ([NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:])
  3. Use [NSFileProviderManager registerURLSessionTask:forItemWithIdentifier:completionHandler:] to build task-identifier mapping.

Then the File Provider extension will show the progress on UI.



来源:https://stackoverflow.com/questions/48906577/nsfileproviderextension-extension-show-download-progress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!