mercredi 26 août 2020

How to get the right selector from URLSession.dataTask(with:completionHandler:) on Xcode 11.5?

On Xcode 11.5 (Swift 5.2.4) the compiler gets confused and shows the error below:

Cannot convert value of type '(URLSession) -> (URL, @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask' to type '(URLSession) -> (URLRequest, @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask' in coercion

I'm trying to get the selector like follows, but the compiler still tries to convert to the version with URL instead:

let selector = #selector(URLSession.dataTask(with:completionHandler:) as (URLSession) -> (URLRequest, @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask)

enter image description here





Aucun commentaire:

Enregistrer un commentaire