Ambiguous reference to member ‘dataTask(with:completionHandler:)’
let request = NSMutableURLRequest(url: URL(string: “Your API URL here” ,param: param))!,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval:”Your request timeout time in Seconds”)
request.httpMethod = “POST”
request.allHTTPHeaderFields = headers as? [String : String]
let dataTask = URLSession.shared.dataTask(with: request ) {data,response,error in
let httpResponse = response as? HTTPURLResponse
if (error != nil) {
print(error)
} else {
print(httpResponse)
}
DispatchQueue.main.async {
//Update UI here
}
}
dataTask.resume()
Solution: just make request as URLRequest
let dataTask = URLSession.shared.dataTask(with: request as URLRequest)
Read More:
- Unity2019.1.02f error cs0104: ‘minattribute’ is an ambiguous reference between
- C# Member XXX cannot be accessed with an instance with an instance reference;qualify it with a type
- Module ‘XX’ has no ‘XX’ member pylint (no member)
- MySQL error: column ‘ID’ in field list is ambiguous
- call to member function bind_param() on boolean………..
- 【ERROR_2】Call to a member function bind_param() on a non-object
- Altium designer failed to add class member problem
- Fatal error: Call to a member function bind_param() on a non-object in
- Visual studio encountered an ambiguous printf
- “Error! Reference source not found.” “error! Reference source not found solution to problem for
- C++ compiler prompt “undefined reference to…”[How to Fix]
- Call to a member function fetch_assoc() on a non-object
- Solutions for undefined reference to ‘xxx’ encountered during linking
- The solution of undefined reference to error
- [Qt] error: call to non-static member function without an object argument
- Altium designer20 failed to add class member: XXX and unknown pin
- main.cpp : (. Text + 0xd06): undefined reference to XX method | simple record
- Try not to use @reference after using Dubbo, which may cause conflicts
- PHP Fatal error: Call to a member function query() on a non-object in
- [C + +] C + + overload operator = must be a nonstatic member function?