title: Get http response status code of URLSession.shared.dataTask
body: <p>I request a web page with this code </p>
  
  <pre><code>URLSession.shared.dataTask(with: NSURL(string: url)! as URL, completionHandler: { (data, response, error) -&gt; Void in
  
  if error == nil &amp;&amp; data != nil {
  // No error
  }else{
  // Error
  if let httpResponse = response as? HTTPURLResponse {
    print(httpResponse.statusCode)
   }
  }
  </code></pre>
  
  <p>I am trying to get the error code when requesting a page by casting the response to <code>HTTPURLResponse</code> but the cast dose not work and the print is not executed. Do you know how can I get the code? </p>