I have a dictionary like this:
var dict=
[ "attractions" : ["ALL" : [], "BY TYPE": []],
"accommodation" : ["ALL" : [] ]
]
And I want to take dynamically the keys and values of this dictionary.
For example I want to take the second key so accommondation
and then check how many keys does this has so 1 and print them.
Finally I want to take the value of a specific key for example I want to take the array of the by type
key (dynamically), so I want something like
dict[0][1]
I found from another question this extension (in swift 2 and I converted in swift 3 so maybe it's not even right) but I can't understand how to use it.
extension Dictionary {
subscript(i:Int) -> (key:Key,value:Value) {
get {
return self[index(startIndex, offsetBy: i)]
}
}
}
Thanks in advance.