Closed yoonjason closed 4 years ago
You cannot cast a regular Dictionary
to OrderedDictionary
. You can use either a dictionary literal or an initializer on OrderedDictionary
which takes a regular Dictionary
and specify the ordering closure (see below).
let dictionary: [String:[[String:AnyObject]]] = [
"A": [],
"C": [],
"B": [],
]
let orderedDictionary = OrderedDictionary(unsorted: dictionary) { element1, element2 in
element1.key < element2.key
}
how to convert [String:[[String:AnyObject]]] to OrderedDictionary type?
let orderedDictionary: OrderedDictionary<String, Any> = (self.dic as? OrderedDictionary)!
warning message Cast from '[String : [[String : Any]]]' to unrelated type 'OrderedDictionary<String, Any>' always fails