Created
July 1, 2020 09:44
-
-
Save archieedwards/a2cc58ab754f4cdf9d4b5c188264300c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol NetworkClientProtocol { | |
func executeRequest(request: URLRequest, completion: @escaping (Data?, Error?) -> Void) | |
} | |
extension URLSession: NetworkClientProtocol{ | |
/// this is where the real request happens | |
func executeRequest(request: URLRequest, completion: @escaping (Data?, Error?) -> Void) { | |
let task = dataTask(with: request) { (data, _, error) in | |
completion(data, error) | |
} | |
task.resume() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment