Last active
November 24, 2015 16:27
-
-
Save philosopherdog/fe80031e408fb3284461 to your computer and use it in GitHub Desktop.
simple nsurlsession playground
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
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