Добавить URLSessionDownloadDelegate
, создать URLSession
с делегатом
URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
_progress = Float(totalBytesWritten) / Float(totalBytesExpectedToWrite)
}