Show loading percentage of image download from url with swift
<p>So I have an image downloading from a url like so</p>

<pre><code>        let request = NSMutableURLRequest(URL: NSURL(string: "\(self.ip)")!)
        request.HTTPMethod = "POST"
        let postString = "userID=\(userID)"
        request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)

        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        let session = NSURLSession(configuration: configuration, delegate: self, delegateQueue: NSOperationQueue.mainQueue())

        let task = session.dataTaskWithRequest(request) {
            data, response, error in
                   .........
        }
</code></pre>

<p>and my delegate functions look like </p>

<pre><code>func URLSession(session: NSURLSession, task: NSURLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) {

    let uploadProgress:Float = Float(totalBytesSent) / Float(totalBytesExpectedToSend)
    let progressPercent = Int(uploadProgress*100)
    print(progressPercent)
}

func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didBecomeDownloadTask downloadTask: NSURLSessionDownloadTask) {
    let downloadProgress:Float = Float(downloadTask.countOfBytesReceived) / Float(downloadTask.countOfBytesExpectedToReceive)
    print(downloadProgress)
}
</code></pre>

<p>The upload progress works just fine for a different function, but when downloading an image, the second URLSession function does not get called. What am I doing wrong?</p>