質問編集履歴
3
変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
配列のなかの辞書を出力したいのになぜかエラーになる
|
2
2
|
swiftの一番苦手な部分です
|
3
3
|
|
4
4
|
エラー文
|
2
変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
なぜ
|
1
|
+
なぜ配列のなかに辞書型があるのにエラーになるのか
|
2
|
-
|
2
|
+
swiftの一番苦手な部分です
|
3
3
|
|
4
4
|
エラー文
|
5
5
|
Cannot subscript a value of type 'Dictionary<String, [String : Any]>.Values' with an index of type 'Int'
|
6
6
|
```swift
|
7
|
-
// エラー
|
7
|
+
// エラー
|
8
8
|
let val = snapshot.value as! [String:[String:Any]]
|
9
9
|
print(val)// [["radius": 200, "longitude": 220.7706379742732, "latitude": 22.80986850432661]]
|
10
10
|
var locationVal:[[String:Any]] = []
|
11
11
|
locationVal += val.values
|
12
|
+
// エラー箇所
|
12
13
|
print(locationVal[0])
|
13
14
|
```
|
14
15
|
|
15
16
|
```swift
|
16
|
-
|
17
|
+
|
17
18
|
let val = snapshot.value as! [String:[String:Any]]
|
18
19
|
print(val)
|
19
20
|
let locationVal = val.values
|
21
|
+
// エラー箇所
|
20
22
|
print(locationVal[0])
|
21
23
|
```
|
1
追加
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|