Back

最简洁的 Alamofire、 SwiftyJSON 和 Haneke 示例

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!)
    }
  }
}
comments powered by Disqus