Skip to content

Instantly share code, notes, and snippets.

@philosopherdog
Last active November 24, 2015 16:27
Show Gist options
  • Save philosopherdog/fe80031e408fb3284461 to your computer and use it in GitHub Desktop.
Save philosopherdog/fe80031e408fb3284461 to your computer and use it in GitHub Desktop.
simple nsurlsession playground
import UIKit
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: "http://www.cocoanutmobile.com")!)
{ data, response, error in
guard error == nil else {
print(error?.localizedDescription)
return
}
guard let data = data else {
print("No data")
return
}
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
}.resume()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment