Reputation: 1027
I want to convert from NSArray
to swift array [Dictionary<String:String>]
Any help ?
Upvotes: 2
Views: 1074
Reputation: 32786
Simple as that:
let someArray = myArray as? [[String:String]]
Optional casting is recommended if you want to make sure you don't get any crashes when converting. You can then use it in if-let
constructions like this:
if let dictArray = myArray as? [[String:String]] {
// do something with the array of dictionaries
}
BTW, your initial definition was not correct, there's no such thing as Dictionary<String:String>
, the correct definition is Dictionary<String, String>
.
Upvotes: 1