Skip to content

Instantly share code, notes, and snippets.

@regularberry
Created September 29, 2018 23:26
Show Gist options
  • Save regularberry/e50afffd5a4be2f6a506327dc3f652b7 to your computer and use it in GitHub Desktop.
Save regularberry/e50afffd5a4be2f6a506327dc3f652b7 to your computer and use it in GitHub Desktop.
class ViewController: UIViewController, URLSessionTaskDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "http://0.0.0.0")!
let data = "Secret Message".data(using: .utf8)!
let request = URLRequest(url: url)
let config = URLSessionConfiguration.background(withIdentifier: "uniqueId")
let session = URLSession(configuration: config, delegate: self, delegateQueue: nil)
let task = session.uploadTask(with: request, from: data)
task.resume()
}
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
print("We're done here")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment