I have some issues with UIProgressView, I dont know why It crashes. In my view controller I have outlet like:
@IBOutlet weak var progressBar: UIProgressView!
and I double checked it connected correctly. In my viewDidLoad I reset the value like:
progressBar.progress = 0.0
Then when I start to download something, I call it like:
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
let written = byteFormatter.string(fromByteCount: totalBytesWritten)
print("print the written \(written)")
let expected = byteFormatter.string(fromByteCount: totalBytesExpectedToWrite)
self.progressBar.progress = Float(100 * bytesWritten/totalBytesExpectedToWrite)
}
but it crash always in this line:
self.progressBar.progress = Float(100 * bytesWritten/totalBytesExpectedToWrite)
Any idea?