我在以下两个数组之间建立关联并获得所需的输出时遇到问题:
场景:
sectionArray
[["mbsdcie6_2_1": Incomer 132 KV Parameters, "mbsdcie6_2_2": <__NSCFArray 0x604000115180>(
3,
6,
4,
5,
8,
30,
31,
7,
18,
29,
1
)
], ["mbsdcie6_2_1": SMS2 Parameters, "mbsdcie6_2_2": <__NSCFArray 0x6040000a3f60>(
9,
10,
11,
12,
13,
14
)
], ["mbsdcie6_2_1": SMS 1 Parameters, "mbsdcie6_2_2": <__NSCFArray 0x604000267880>(
15,
17
)
]]
ParamName
["Date", "Sync Time", "UUC2T7", "Set MD", "Total KVA", "Total KW", "Running MD", "SMS 1 KW", "P.F.", "ET-5 KW", "ET-3_4 KW", "ET- 6_7 KW", "ABP-1 KW", "ABP-1A KW", "ABP-2 KW", "G-22 KW", "UUC36T37", "G-23 KW", "WRM KW", "Total KWH", "Total KVAH", "ET-5 KWH", "ET-3_4 KWH", "ET-6_7 KWH", "ABP-1 KWH", "ABP-1A KWH", "ABP-2 KWH", "SMS 1 KWH", "UUC60T73", "PLC Time", "Voltage", "Current", "Load Factor", "Avg. P.F."]
问题:
例如:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "DataMonitorCell", for: indexPath) as! DataMonitorCell
cell.lblParameter.text = "Set MD" // value as per the index value 3 of key "mbsdcie6_2_2" from sectionArray
return cell
}
编辑1:
这是我检索sectionArray的方式:
var sectionArray =字典
覆盖func viewWillAppear(_动画:Bool){ sectionArray = kUserDefault.array(forKey:kHeadersArray)为! [字典]
print(sectionArray)
}
这是我检索ParamName的方式
///在另一个ViewController中,我这样检索它:
var paramName =字符串
覆盖func viewWillAppear(_动画:布尔){
paramName = kUserDefault.value(forKey: kParameterNameArray) as! [String]
print(paramName)
}
我尝试了很多方法,但是对我来说似乎很复杂。任何帮助将不胜感激,谢谢!