Created
September 29, 2018 23:26
-
-
Save regularberry/e50afffd5a4be2f6a506327dc3f652b7 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 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