Skip to content

Instantly share code, notes, and snippets.

@licvido
Created February 3, 2015 19:11
Show Gist options
  • Save licvido/aca18f5bbd38e7e8e874 to your computer and use it in GitHub Desktop.
Save licvido/aca18f5bbd38e7e8e874 to your computer and use it in GitHub Desktop.
SWIFT: HTTP request
let url = NSURL(string: "http://www.example.com")
let request = NSURLRequest(URL: url!)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
// ...
}
let url = NSURL(string: "http://www.example.com")
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
// ...
}
task.resume()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment