Let\'s assume I have a dictionary that accepts a string as the key and an array as value:
var d = [String: [Int]]() d[\"k\"] = [Int]()
Now I wo
If the element for that key exists, you can simply do:
d["k"]?.append(1)
Note that if no element exists for the "k" key, then nothing happens. If you want to ensure there's actually an array for that key, just add this before appending:
"k"
if d["k"] == nil { d["k"] = [] }