Skip to content

Instantly share code, notes, and snippets.

@paulw11
Created April 1, 2016 10:30
Show Gist options
  • Select an option

  • Save paulw11/90834a063d8e5ac715b8ed064e00544e to your computer and use it in GitHub Desktop.

Select an option

Save paulw11/90834a063d8e5ac715b8ed064e00544e to your computer and use it in GitHub Desktop.
import XCPlayground
import Foundation
XCPlaygroundPage.currentPage.needsIndefiniteExecution=true
var imageURL = NSURL(string : "https://www.nasa.gov/sites/default/files/wave_earth_mosaic_3.jpg")
if let url = imageURL{
let task = NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data, response, error) in
if (error != nil) {
print("The error is \(error!)")
} else {
if let theData=data {
print("The data length is \(theData.length)")
}
}
})
task.resume()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment