Created
July 6, 2017 00:15
-
-
Save jxq0/55a4c0e079727dc272a88bf77d13b718 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let getImage = {[unowned self](data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in | |
let sizeOrder = ["Large", "Medium 800", "Medium 640"] | |
var largestImgUrl: String? | |
let json = JSON(data: data) | |
for (index: String, subJson: JSON) in json["sizes"]["size"] { | |
for size in sizeOrder { | |
if (subJson["label"].string == size) { | |
largestImgUrl = subJson["source"].string | |
break | |
} | |
} | |
} | |
let photoUrl = NSURL(string: largestImgUrl!) | |
var manager: SDWebImageManager = SDWebImageManager.sharedManager() | |
manager.downloadImageWithURL( | |
photoUrl, | |
options: SDWebImageOptions.ProgressiveDownload, | |
progress: nil) | |
{[unowned self]( | |
cellImage: UIImage!, | |
error: NSError!, | |
cacheType: SDImageCacheType, | |
finished: Bool, | |
imageUrl: NSURL!) -> Void in | |
self.photoView?.image = cellImage | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment