Skip to content

Instantly share code, notes, and snippets.

View Lucien's full-sized avatar
🐍

Lucien Doellinger Lucien

🐍
View GitHub Profile
//MARK: - URLSessionDataDelegate
extension ViewController: URLSessionDataDelegate {
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else {
completionHandler(.cancel)
return
}