Skip to content

Instantly share code, notes, and snippets.

@dorentus
Last active August 29, 2015 14:02
Show Gist options
  • Save dorentus/2c5bbf97a3ac2f7c016c to your computer and use it in GitHub Desktop.
Save dorentus/2c5bbf97a3ac2f7c016c to your computer and use it in GitHub Desktop.
import Foundation
let url = NSURL(string: "https://spdy.today/spdy.json")
let request = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.currentQueue()) {
_, data, _ in
if data {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println(str)
}
}
import Foundation
let url = NSURL(string: "https://spdy.today/spdy.json")
let request = NSURLRequest(URL: url)
let data = NSURLConnection.sendSynchronousRequest(request, returningResponse: nil, error: nil)
if data {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println(str)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment