我花了一些时间尝试搜索这个,但我还没有找到解决方案。我试图访问字典中的特定数组值。以下是我想要做的一般代码/解释。
var dict = ["1": [1,2,3,4,5], "2": [6,7,8,9,10], "3": [11,12,13,14,15]]
//now lets say I want to access the 3rd value of dict["2"] = 8
//I have tried the following and failed
print(dict["2": [2]])
print(dict["2"][2])
由于
答案 0 :(得分:0)
以下是实现这一目标的方法:
var dict = ["1": [1,2,3,4,5], "2": [6,7,8,9,10], "3": [11,12,13,14,15]]
let temp = dict["2"]![2] // 8