【发布时间】:2016-03-07 21:50:32
【问题描述】:
我正在尝试使用 Alomofire 和 swiftyJSON 从 json 加载图像。 Json 是字典:
{"name": {"image": "https://...",}}
Alamorefire 和 SwiftyJSON
var imageLoad: String!
Alamofire.request(.GET, url).responseJSON { (response) -> Void in
if let value = response.result.value {
let json = JSON(value)
if let jsonDict = json.dictionary {
let image = jsonDict["name"]!["image"].stringValue
print(image) // https://....
self.imageLoad = image
}
self.tableView.reloadData()
}
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! TVCell
// Configure the cell...
cell.imageTableView.image = UIImage(named: imageLoad) // not working "fatal error: unexpectedly found nil while unwrapping an Optional value"
如果有人可以帮忙?如果有其他方式,请随时写。
【问题讨论】:
标签: ios uitableview swift2