gpt4 book ai didi

swift - 如何使用 for 循环实例化字典(swift)

转载 作者:行者123 更新时间:2023-11-30 13:15:47 24 4
gpt4 key购买 nike

private var selectedButtonArray = [UIButton]() 
private var buttonStepperDictionaryArray = [NSMutableDictionary]()

func appendToButtonStepperDictionaryArray(ixSelectionItem: IxSelectionItem...){
for iSelectionItem in selectedButtonArray{
buttonStepperDictionaryArray.append("buttonDesc":iSelectionItem.button.text,"dsds":iSelectionItem.button.tag)
}
}

结果应如下所示:

[{"buttonDesc":"abc","buttonTag":1},
{"buttonDesc":"bcd","buttonTag":2},
{"buttonDesc":"ddd","buttonTag":3}]

我怎样才能做到这一点?

最佳答案

试试这个

private var selectedButtonArray = [UIButton]()
private var buttonStepperDictionaryArray = [NSMutableDictionary]()

func appendToButtonStepperDictionaryArray(ixSelectionItem: IxSelectionItem){
for iSelectionItem in selectedButtonArray{
buttonStepperDictionaryArray.append(["buttonDesc": ixSelectionItem.button.text,"dsds":iSelectionItem.tag])
}
}

关于swift - 如何使用 for 循环实例化字典(swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38239039/

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