定义多维数组的数据类型

时间:2016-03-15 14:19:06

标签: arrays swift multidimensional-array

如何声明以下多维数组的数据类型

settings = [

        “person" : [

            “name”:"bing",

            "status”:"done",

        ],

        “flags" : [

            “moved" :true

        ]

    ]

尝试使用var settings = [String]()var settings = [String[String:String]但无效

1 个答案:

答案 0 :(得分:1)

纠正所有小错误后(您使用代替"

let settings = ["person": ["name": "bing", "status": "done"], "flags": ["moved": true]]

Alt点击设置显示:

let settings: [String : Dictionary<String, NSObject>]

但您也可以将其声明为[String: [String: AnyObject]]