I have an array ([Dictionary<String, String>]
) of dictionary, say,
let dict0 = ["0": 1, "1": 2, "2": 4]
let dict1 = ["0": 5, "1": 4, "2": 8]
let dict2 = ["0": 3, "1": 9, "2": 7]
let array = [dict0, dict1, dict2]
So it looks like the following.
[ ["0": 1, "1": 2, "2": 4], ["2": 8, "0": 5, "1": 4], ["2": 7, "1": 9, "0": 3] ]
Let me assume that I have an array ([String]
) of keys like
let keys = ["ant", "bee", "spider"]
Is there a simple way of changing my array's keys such that it will look like the following?
[ ["ant": 1, "bee": 2, "spider": 4], ["spider": 8, "ant": 5, "bee": 4], ["spider": 7, "bee": 9, "ant": 3] ]
Thanks.