Last active
August 10, 2017 16:33
-
-
Save koromiko/c29de5e895ec20620e9c0a402ccf45f6 to your computer and use it in GitHub Desktop.
This file contains 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
class HttpClient { | |
typealias completeClosure = ( _ data: Data?, _ error: Error?)->Void | |
func get( url: URL, callback: @escaping completeClosure ) { | |
let request = NSMutableURLRequest(url: url) | |
request.httpMethod = "GET" | |
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in | |
callback(data, error) | |
} | |
task.resume() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment