title: Download Image from Url iOS 10 Swift 3
body: <p>This is the function i used before to download image from url. I was using <strong>swift 2.3</strong> version.</p>
  
  <pre><code>let request: NSMutableURLRequest = NSMutableURLRequest(URL: url)
  NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse?, data: NSData?, error: NSError?) -&gt; Void in
    if (error == nil) {
      let image: UIImage = UIImage(data: data!)!
      completionBlock(succeeded: true, image: image)
    }
    else {
      completionBlock(succeeded: false, image: UIImage(named: "user_icon")!)
    }
  })
  </code></pre>
  
  <p>Now i have converted the code to <strong>Swift 3</strong> and the new code is given below. The below code is not calling the completion handler. Can anyone help me with this? Here is the swift 3 code.</p>
  
  <pre><code>let sessionTask = URLSession.shared
  let request = URLRequest(url: url)
  sessionTask.dataTask(with: request, completionHandler: {(data: Data?, response: URLResponse?, error: Error?) -&gt; Void in
    if (error == nil) {
      let image: UIImage = UIImage(data: data!)!
      completionBlock(true, image)
    }
    else {
      completionBlock(false, UIImage(named: "user_icon")!)
    }
  })
  </code></pre>