我正在使用Alamofire和SwiftyJSON。我可以成功地读取API如下:从字典数组中读取int(NSCFNumber)
Alamofire.request(.GET, "https://jsonplaceholder.typicode.com/posts").responseJSON { (responseData) -> Void in
if((responseData.result.value) != nil) {
let swiftyJsonVar = JSON(responseData.result.value!)
if let resData = swiftyJsonVar.arrayObject {
self.arrRes = resData as! [[String:AnyObject]]
}
if self.arrRes.count > 0 {
self.results_tableView.reloadData()
}
} }
但我不能获取值字典[“ID”]和字典[“用户id”]从字典中的单元格中显示。
var dict = arrRes[indexPath.row]
cell.label_body.text = dict["body"] as? String
cell.label_title.text = dict["title"] as? String
cell.label_id.text = dict["id"] as? String **//prints (nil)**
cell.label_userId.text = dict["userId"] as? String **//prints (nil)**
这是我的字典的数组的顶部的信息声明:
var arrRes = [[String:AnyObject]]() //Array of dictionary
非常感谢您的任何帮助。
非常感谢你“桑托斯”。你的回答是真实的,但是我接受他,就像我之前看到的那样。 – Umitk