我想创建字典发送给API服务器,例如:
var member = ["Member":["Name":"John"],["ID":"001"],["Name":"Andy"],["ID","002"]]
如何在Swift for
循环中使用?
我使用:
member.updateValue([["Name":"Chris"],["ID","004"]], forKey: "Member")
它打印:
["Member":["Name":"Chris"],["ID","004"]]
答案 0 :(得分:0)
首先,您更改字典结构 您可以添加新元素
var member = ["Member":[["Name":"John"],["ID":"001"],["Name":"Andy"],["ID","002"]]]
member["Member"]!.insert((["Name":"Chris"],["ID","004"]), at: 0)
print("member = \(member)")