配列のなかの辞書を出力したいのになぜかエラーになる
swiftの一番苦手な部分です
エラー文
Cannot subscript a value of type 'Dictionary<String, [String : Any]>.Values' with an index of type 'Int'
swift
1// エラー 2 let val = snapshot.value as! [String:[String:Any]] 3 print(val)// [["radius": 200, "longitude": 220.7706379742732, "latitude": 22.80986850432661]] 4 var locationVal:[[String:Any]] = [] 5 locationVal += val.values 6 // エラー箇所 7 print(locationVal[0])
swift
1 2 let val = snapshot.value as! [String:[String:Any]] 3 print(val) 4 let locationVal = val.values 5 // エラー箇所 6 print(locationVal[0])
回答1件
あなたの回答
tips
プレビュー