I migrated my project (initially developed in Swift 2.2
) to Swift 3
but I encounter an error with the following code:
let url:URL = URL(string: url_to_request)!
//let session = NSURLSession.sharedSession()
let configuration = URLSessionConfiguration.default
let session = Foundation.URLSession(configuration: configuration,
delegate: self,
delegateQueue:OperationQueue.main)
let request = NSMutableURLRequest(url: url)
request.httpMethod = "GET"
request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringCacheData
request.timeoutInterval = 10
let task = session.dataTask(with: request, completionHandler: {
(
data, response, error) in
if(response == nil){
print("erreur de connexion....")
result = false
callback(result)
}
I have the following error
Ambiguous reference to member 'dataTask(with:CompletionHandler:)'
I've seen that in Swift3
we may use NSURLSession.sharedSession()
but as I'm using a Customized session, it will not work as I'm expecting...
Any idea how can I solve it ?