I have searched but haven't found a relevant answer only in Objective C. Is there a way to find the progress of the download of a file in Swift, so that to show it to user? I am new to iOS programming and I have tried with NSURLSession but without success.
EDIT: I have used this method as seen in this post, but I can't seem to understand how to get the progress status:
func downloadFile(page: NSString){
finished = false
var statusCode:Int = 0
println("Download starting")
let url = NSURL(string: page)
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
if error != nil {
println("download failed with error \(error?.localizedDescription)")
} else {
println("Expected Content-Length \(response.expectedContentLength)")
self.contentLength = response.expectedContentLength
if let httpResponse = response as? NSHTTPURLResponse {
println("Status Code of number \(self.countDownload) is \(httpResponse.statusCode)")
statusCode = httpResponse.statusCode
}
}
}
task.resume()
}
Thank you in advance