最简洁的 Alamofire、 SwiftyJSON 和 Haneke 示例

Unless otherwise indicated, the text of documents in this site is available under the Creative Commons Attribution 3.0 Unported License, or any later version. Copyright 2009 - 2017 leopku.
import Alamofire
import SwiftyJSON
import Haneke

@IBOutlet weak var imageView: UIImageView!

Alamofire.request(.GET, "http://jsonplaceholder.typicode.com/photos").responseJSON { (request, response, json, error) in
  // println(json)
  if (json != nil){
    var photo = JSON(json!)
    // println(photo[0]["url"])
    if let urlString = photo[0]["url"].string {
      self.urlString = urlString
      let url = NSURL(string: urlString)
      self.imageView.hnk_setImageFromURL(url!)
    }
  }
}

Related Posts