gpt4 book ai didi

arrays - 从 [String]() 数组设置单元格 textLabel

转载 作者:行者123 更新时间:2023-11-30 10:13:22 25 4
gpt4 key购买 nike

尝试访问我的单元格 textLabel 和详细信息文本标签并将其设置为我已附加到数组的对象。我不确定在这种情况下如何使用正确的语法。感谢您的帮助!

这是我在 for 循环中通过解析附加的对象。

var customers = [String]()


for object in objects {

self.customers.append(object["customerName"] as! String)
self.customers.append(object["customerStreetAddress"] as! String)

cellForRowAtIndexPath {


cell.textLabel.text = //I want the objects["customerName"] here
cell.detailTextLabel.text = // objects["customerStreetAddress"] here
}

最佳答案

你可以试试这个。

var customers = [String]()
var number = -1

for object in objects {

self.customers.append(object["customerName"] as! String)
self.customers.append(object["customerStreetAddress"] as! String)

cellForRowAtIndexPath {

++number
if number + 1 <= customers.count {
cell.textLabel.text = customers[number]//I want the objects["customerName"] here
}
++number
if number + 1 <= customers.count {
cell.detailTextLabel.text = customers[number]// objects["customerStreetAddress"] here
}
}
}

关于arrays - 从 [String]() 数组设置单元格 textLabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31665171/

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