我有一个非常简单的例子,说明我想做什么
private var data = [String: [[String: String]]]() override func viewDidLoad() { super.viewDidLoad() let dict = ["Key": "Value"] data["Blah"] = [dict,dict] } @IBAction func buttonTap(sender: AnyObject) { let array = data["Blah"] let dict = array[0] //<---- error here println(dict["Key"]) }
基本上,我有一个字典,其值包含[String:String]字典数组.我把数据填入其中,但当我去访问数据时,我收到此错误:
Cannot subscript a value of type ‘[([String : String])]?’ with an
index of type ‘Int’
请让我知道我做错了什么.