更新时间:2022-06-09 00:38:25
您正尝试遍历数组,将其视为字典. 您必须遍历数组,然后遍历键/值对
You are trying to iterate through an array treating it like a dictionary. You'll have to iterate through the array and then through your key/value pairs
for dictionary in arrayOfMutatingDictionaries{
for (key,value) in dictionary{
//Do your stuff
}
}
添加键/值对非常简单.
Adding a key/value pair is pretty straightforward.
for i in 0..< arrayOfMutatingDictionaries.count{
arrayOfMutatingDictionaries[i][yourkey] = yourvalue
}
您还可以像这样增加现有值
You can also increment the existing values like this
for i in 0..<arrayOfMutatingDictionaries.count{
for (key,value) in arrayOfMutatingDictionaries[i]{
arrayOfMutatingDictionaries[i][key] = value+1
}
}