title: iOS-Swift How to update progressView
body: <p>I am developing an app where i am downloading data from web.
  here i am using cancel button to cancel the download progress,this works fine if i am in the same view controller and if i navigate to new view controller and return back to download view controller progress view is not updating but the download is happening. </p>
  
  <p>This is the code i am using to download data</p>
  
  <pre><code>func URLSession(session: NSURLSession,
                  downloadTask: NSURLSessionDownloadTask,
                  didFinishDownloadingToURL location: NSURL){
  
      let path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
      let documentDirectoryPath:String = path[0]
      let fileManager = NSFileManager()
      let destinationURLForFile = NSURL(fileURLWithPath: documentDirectoryPath.stringByAppendingString( Variables.name ))
  
      if fileManager.fileExistsAtPath(destinationURLForFile.path!){
          print("File Already Exists")
      } else {
          do {
              try fileManager.moveItemAtURL(location, toURL: destinationURLForFile)
              print("File doesn't exists")
          }catch{
              print("An error occurred while moving file to destination url")
          }
      }
  }
  
  // 2
  func URLSession(session: NSURLSession,
                  downloadTask: NSURLSessionDownloadTask,
                  didWriteData bytesWritten: Int64,
                               totalBytesWritten writ: Int64,
                               totalBytesExpectedToWrite exp: Int64){
      //progressView.setProgress(Float(totalBytesWritten)/Float(totalBytesExpectedToWrite), animated: true)
  
      print("downloaded \(100*writ/exp)")
  
      dispatch_async(dispatch_get_main_queue(), {
          self.counter = Float(100*writ/exp)
          return
      })
  }
  
  func URLSession(session: NSURLSession,
                  task: NSURLSessionTask,
                  didCompleteWithError error: NSError?){
      downloadTask = nil
  
      //  progressView.setProgress(0.0, animated: true)
      if (error != nil) {
          print(error?.description)
      } else {
          print("The task finished transferring data successfully")
      }
  }
  
  func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) -&gt; UIViewController{
      return self
  }
  </code></pre>