title: URLSession Error Swift 3
body: <p>I have the following code:</p>
  
  <pre><code>func downloadItems() {
  
      let url: NSURL = NSURL(string: urlPath)!
      var session: URLSession!
      let configuration = URLSessionConfiguration.default
  
      session = URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
  
      let task = session.dataTask(with: url as URL)
  
      task.resume()
  
  }
  </code></pre>
  
  <p>This is from an older project online, and Swift is giving me this error code: </p>
  
  <blockquote>
    <p>'URLSession' produces '()', not the expected contextual result type 'URLSession!'.</p>
  </blockquote>
  
  <p>I've found other people asking about this on Stock Overflow, but all the answers are for older versions of Swift, and result in other errors.</p>
  
  <p>Here are the other questions I found:</p>
  
  <p><a href="https://stackoverflow.com/questions/39634475/how-to-set-urlsession-swift-3">How to set URLSession Swift 3</a> </p>
  
  <p><a href="https://stackoverflow.com/questions/40347832/urlsession-error">URLSession error</a></p>