I want to store the progress of progressView into arraylist as one element
I decleared the array like this
var prog = [Float]()
and i'm getting the progress like this
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
if totalBytesExpectedToWrite > 0 {
progressVi = Float(totalBytesWritten) / Float(totalBytesExpectedToWrite)
print(progressVi)
}
}
I tried this to store it
prog.insert(progressVi, at: 0)
but I'm getting it like this
[0.0071399305, 0.004518387, 0.002777841, 0.0012658517, 0.00086148235, 0.00063292583, 0.000580182, 0.0005274382, 0.0001557393]
and it's keep adding ...
So how can I store it as one element?