Created
March 21, 2018 10:28
-
-
Save olbrichj/9034a7c4635a4e2866aba5ffebc2ef79 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
public class ApiRequestDelegate:NSObject, URLSessionDelegate, URLSessionTaskDelegate, | |
URLSessionDataDelegate{ | |
// called once as soon as a response returns | |
public func urlSession(session: URLSession, dataTask: URLSessionDataTask, | |
didReceiveResponse response: URLResponse, | |
completionHandler: (URLSession.ResponseDisposition) -> Void) { | |
// store Response to further process it and call completion Handler to continue | |
} | |
// called when finished | |
public func urlSession(session: URLSession, task: URLSessionTask, | |
didCompleteWithError error: NSError?) { | |
// handle errors and e.g. call a completion handler so you can continue with your tasks or start a different request | |
} | |
// called if data is not returned in one block | |
public func urlSession(_: URLSession, dataTask: URLSessionDataTask, | |
didReceive data: NSData) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment