Skip to content

Instantly share code, notes, and snippets.

@fortmarek
Created June 18, 2019 19:10
Show Gist options
  • Save fortmarek/8a06f6729dae636435d35ab419e0ee4b to your computer and use it in GitHub Desktop.
Save fortmarek/8a06f6729dae636435d35ab419e0ee4b to your computer and use it in GitHub Desktop.
private var urlSession: URLSession?
private func upload() {
if urlSession == nil {
let config = URLSessionConfiguration.background(withIdentifier: (Bundle.main.bundleIdentifier ?? "") + UUID().uuidString)
urlSession = URLSession(configuration: config, delegate: self, delegateQueue: nil)
}
}
extension ViewController: URLSessionDelegate, URLSessionTaskDelegate, URLSessionDataDelegate {
func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?) {}
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {}
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment