編輯:不是重複:Swift:無法下標'Dictionary <String,NSObject>?'類型的值
該解決方案提供了'Could not find an overload for 'subscript' that accepts the supplied arguments'
錯誤。所以,這不是重複的。
這裏是函數聲明。
func auth(user: String, pass: String, completion: (returned: Bool, error: Bool, response: Dictionary<String, NSObject>?) ->()){
response
可以是零 }
現在我想要訪問在另一個文件傳回值,並得到一個錯誤:
if let labelString = response["error_description"] as! String?{
self.labelPrompt.text = labelString
}
錯誤:不能下標值類型'字典'?與類型的索引「字符串」
可能重複的 '\ [NSObject的:AnyObject \]'與索引類型'String'](http://stackoverflow.com/questions/29994541/cannot-subscript-a-value-of-type-nsobject-anyobject-with-an-index-of-type) – Moritz
它**是**重複。見下面Eric D的正確答案。 (投票) –