gpt4 book ai didi

swift -4 : How to assign NSArray of NSDictionary values to another NSDictionary variable and how do i get value for key from NSDictionary

转载 作者:行者123 更新时间:2023-11-30 11:34:40 27 4
gpt4 key购买 nike

在 Objective 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 */

最佳答案

试试这个

var dictValue = array[indexPath.row] as? [AnyHashable: Any]
cell.name.text = dictValue?["customer_name"]

关于 swift -4 : How to assign NSArray of NSDictionary values to another NSDictionary variable and how do i get value for key from NSDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49891921/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com