我希望在swift中创建一个具有不同类型数据(数组、字符串、字典)的字典。我可以将新数据插入到键中,但在向它们添加更多值时遇到了困难。下面是该字典的JSON:
{
"GenInfo": {
"First Name":"Varun",
"Last Name":"Naharia",
"Phone No":"123456789"
},
"LangInfo": ["Hindi","English","Urdu","French"],
"EduInfo":
[
{
"Collage":"CIITM",
"Year":"2009",
"Degree":"BCA"
},
{
"Collage":"Dept. Of Comp. Sci. & Infor. University Of Kota",
"Year":"2013",
"Degree":"MCA"
}
]
}
我想逐一将这些值添加到字典中,例如先加入GenInfo,然后是LangInfo的第一种语言,最后是EduInfo。
Lang Info
EduInfo
我使用dict["GenInfo"] = ["FirstName":first,"LastName":last,"Phone":phone]
将GenInfo添加到字典中,其中first和last是具有值的变量。
EDIT #1
var dict = Dictionary<String, Any>()
dict["Language"]=[lang]
- Varun Naharia