team: [
[
{
type: "profile",
assists: 8,
},
{
type: "profile",
assists: 9,
},
],
[
{
type: "profile",
assists: 8,
},
{
type: "profile",
assists: 9,
},
]
]
这是我的数据,如何声明变量?
var info = Array<Dictionary<String, String>()>
var info = Array<Dictionary<String, Int>()>
都不行
我要编辑变量添加字典。 我该如何申报?
答案 0 :(得分:2)
您可以使用以下语法:
var info = [[[String: AnyObject]]]()
更好的是,您可以使用struct
:
struct TeamMember {
var type: String
var assists: Int
}
var test: [[TeamMember]] = [
[
TeamMember(type: "x", assists: 0),
TeamMember(type: "x", assists: 0)
],
[
TeamMember(type: "x", assists: 0),
TeamMember(type: "x", assists: 0)
]
]
答案 1 :(得分:0)
我猜您的类型如下:[[[String:AnyObject]]],一个包含字符串键和未定义对象的字典数组数组。