在目标C中,我们将字典值的NSArray分配给NSDictionary变量并获取密钥的值,如下所示NSDictionary *dictValue = [array objectAtIndex:indexPath.row]
和cell.name.text = [dictValue valueForKey:"customer_name"]
,以便如何在swift-4中进行上述编码。我声明NSArray变量的方式,将字典值数组绑定到另一个NSDictionary以及从NSDictionary获取值的方法。
var leadsArray = [NSArray]() /* Declared NSArray Variable */
let dictValue = larray[indexPath.row] as NSDictionary! /* Assigning each array of dictionary by row count */
cell.label1.text = dictValue["customer_name"] /* Getting valuefor key from NSDictionary Varibale */
答案 0 :(得分:0)
试试这个
var dictValue = array[indexPath.row] as? [AnyHashable: Any]
cell.name.text = dictValue?["customer_name"]
答案 1 :(得分:0)
您可以使用:
let arrResponse = yourRespons as! [String:Any]
let name = arrResponse["customer_name"] as! String
print(name)