1

I am Trying show image from firebase database to tableview but getting error.

Ambiguous reference to member 'dataTask(with:completionHandler:)'

let url = NSURL(string: profileImageUrl)
let session = URLSession.shared
let task = session.dataTask(with: url) { (data, response, err) in
    if err != nil {
       return
    }
    cell.imageView?.image = UIImage(data: data)
}          
task.resume()
Jay
  • 34,438
  • 18
  • 52
  • 81

1 Answers1

1

as from swift 3 version , Swift Standard Library includes Foundation framework classes without 'NS' prefix; so since you are using URLSession instead of NSURLSession, you must use URL instead of NSURL to make both classes compatible with each other in URLSession instance method 'dataTask(with:completionHandler:)'.

just declare url as

let url = URL(string: profileImageUrl)

and done.

praths
  • 353
  • 1
  • 14