Skip to content

Instantly share code, notes, and snippets.

View adamdahan's full-sized avatar
🎯
Focusing

Adam Dahan adamdahan

🎯
Focusing
  • Toronto
View GitHub Profile
![Ruby cheatsheet version 0.1](https://github.com/adamdahan/lighthouse-web/blob/master/ruby-cheatsheet-v-0.1/image/ruby-cheatsheet-v-0.1.png)
@adamdahan
adamdahan / download-image.swift
Last active October 26, 2015 18:32
Async image download swift
var image: UIImage?
var imageURL = "Some url"
if let url = NSURL(string: imageURL) {
let request: NSURLRequest = NSURLRequest(URL: url)
let mainQueue = NSOperationQueue.mainQueue()
NSURLConnection.sendAsynchronousRequest(request, queue: mainQueue, completionHandler: { (response, data, error) -> Void in
if error == nil {
let image = UIImage(data: data)
dispatch_async(dispatch_get_main_queue(), {
// Update image
@adamdahan
adamdahan / gist:810f73ff9d89a0f32c53
Created May 20, 2015 17:34
Get the class name of an AnyObject in Swift
let className = NSStringFromClass(obj.dynamicType)