我刚刚在文件“Celda”中创建了一个新的自定义单元格,现在我需要使用 JSON 在我的 UITableView 中使用标签。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell : Celda = tableView.dequeueReusableCellWithIdentifier("jsonCell")!
var dict = arrRes[indexPath.row]
cell.nombre1.text = dict["nombre"] as? String
cell.nombre2.text = dict["calle"] as? String
cell.id.text = dict["id"] as? String
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrRes.count
}
但我在“let”行中遇到错误。它说:无法将“UITableViewCell”类型的值转换为指定类型“Celda”
。
最佳答案
尝试
let cell = tableView.dequeueReusableCellWithIdentifier("jsonCell") as! Celda
关于ios - 无法将类型 'UITableViewCell' 的值转换为指定类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35091383/