0

In Swift 3 I am getting an error on th is line of code:

let task = getURLSession().dataTask(with: request ) {
        (data, response, error) in

The error is "Ambiguous reference to member 'dataTask(with:completionHandler:)' I'm not sure how to fix it. It worked fine in 2.3.

Floyd Resler
  • 1,786
  • 3
  • 22
  • 41
  • Can you show us a minimized code to reproduce your issue? That two line cannot generate "Ambiguous reference ...", if I fill out other parts with my guess. – OOPer Aug 01 '16 at 21:41
  • 1
    Frequently these sorts of errors arise if there are other problems, e.g. `getURLSession()` isn't returning what you think it should, or if `request` isn't of the type you think it is. Or sometimes it can be a result of some completely unrelated error on some preceding line. – Rob Aug 01 '16 at 21:51
  • You are probably passing a NSMutableRequest when you should be passing a URLRequest. To make it "mutable" just declare it using `var request = URLRequest()` – Leo Dabus Aug 01 '16 at 23:30

0 Answers0