Skip to content

Instantly share code, notes, and snippets.

@pilky
Created February 28, 2017 10:45
Show Gist options
  • Save pilky/c3248fc725e5e9db86ae270fd7d8a474 to your computer and use it in GitHub Desktop.
Save pilky/c3248fc725e5e9db86ae270fd7d8a474 to your computer and use it in GitHub Desktop.
Swift compiler oddity
protocol URLSessionProtocol {
func dataTask(with url: URL, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTaskProtocol
}
protocol URLSessionDataTaskProtocol {
func resume()
}
extension URLSessionDataTask: URLSessionDataTaskProtocol {}
//Compiler complains of non conformance here
//Need to implement method and do casts to URLSessionDataTaskProtocol
extension URLSession: URLSessionProtocol {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment