swift: modifying arrays inside dictionaries

后端 未结 5 954
我寻月下人不归
我寻月下人不归 2020-11-30 11:16

How can I easily add elements to an array inside a dictionary? It\'s always complaining with could not find member \'append\' or could not find an overloa

5条回答
  •  醉话见心
    2020-11-30 11:42

    Use 'for in', for getting values from dictionary's inside array. Here's an example to help you

    var a = ["x":["a","b","c"], "y":["d"]]
    
    for b in a {
        print(b)
    }
    

    Output:

    ("x", ["d"])
    ("y", ["a", "b", "c"])
    

提交回复
热议问题