title: Cannot get data from URLSessionTaskDelegate
body: <p>I am trying to add background fetch capability to my app. Currently, the delegate function <code>urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL)</code> is called after the network call is complete, but the URL in the cache directory does not exist:</p>
  
  <pre><code>class DownloadManager: NSObject, URLSessionTaskDelegate, URLSessionDownloadDelegate {
  
  static var shared = DownloadManager()
  
  var session : URLSession {
      get {
          let config = URLSessionConfiguration.background(withIdentifier: "my_Identifier")
          return URLSession(configuration: config, delegate: self, delegateQueue: OperationQueue())
      }
  }
  
  func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
      print(location.absoluteString)
      do {
          let myData = try Data(contentsOf: location)
      } catch let error {
          print(error.localizedDescription)
        // The The file “file_id.tmp” couldn’t be opened because there is no such file.
      }
  }
  
  public func fetch() {
      guard let url = URL(string: "#{myURL}") else {
          return
      }
  
      let task = session.downloadTask(with: url)
      task.resume()
    }
  }
  </code></pre>
  
  <p>And in my App Delegate:</p>
  
  <pre><code>func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -&gt; Void) {
      print("Executing background fetch")
      DownloadManager.shared.fetch()
      completionHandler(.newData)
  }
  </code></pre>
  
  <p>What am I missing?</p>