如何在特定的索引swift中将元素追加到字典中

时间:2018-03-03 12:18:54

标签: swift

嘿我试着基本上能够将新索引放在字典中的第一个或最后一个。

到目前为止我能够模拟的东西 代码:

 // no success

 var updatedList = [String: AnyObject]()

 updatedList.updateValue(child as AnyObject, forKey: "0")

 or 

 updatedList[child]


 to simply get child in array, I'm trying to figure out how to put it last or first in the dictionary 

1 个答案:

答案 0 :(得分:2)

您无法使用Dictionary执行此操作,因为它没有排序条件,只有您可以为密钥添加元素,这种方式只能在Array

相关问题