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

前端 未结 1 1155
小蘑菇
小蘑菇 2021-01-26 18:25

Hi I have just done a conversion to Swift 3.0 and have had quite a few errors returned. The first one is:

Ambiguous reference to member \'dataTask(with:co

相关标签:
1条回答
  • 2021-01-26 19:07

    try something like this

     guard let requestUrl = URL(string:yourUrlString) else { return }
     let request = URLRequest(url:requestUrl)
     let task = session.dataTask(with: request) {
        (data, response, error) in
        if error == nil {
            //JSONSerialization
        }
     }
    
    0 讨论(0)
提交回复
热议问题