I have 2 view controllers. In the parent view, i have a progress view. In the child VC, I am uploading an image with parameters using POST request to the server and then dismissing that VC and hence on returning to parent VC, I want progress View to update as the upload is happening. I tried protocol-delegate method, but looks like it only works once and can't return values dynamically. I tried implementing the following method in both view controllers but no success.
func URLSession(session: NSURLSession, task: NSURLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) {
self.progressView.hidden = false
self.uploadProgress = Float(totalBytesSent) / Float(totalBytesExpectedToSend)
print(self.uploadProgress)
self.progressView.setProgress(self.uploadProgress, animated: true)
if (uploadProgress == 1.0) {
self.progressView.hidden = true
// uploadProgress = 0.0
}
}