回答編集履歴
1
記載内容の修正
answer
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
-
|
1
|
+
これで取れませんかね?
|
2
2
|
```
|
3
|
+
@IBAction func othersLocation(_ sender: Any)
|
3
|
-
|
4
|
+
{
|
5
|
+
//Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional valueのエラー
|
6
|
+
ref.child("users").child("userCoordinate").observeSingleEvent(of: .value, with: { (snapshot) in
|
7
|
+
let value = snapshot.value as? NSDictionary
|
4
|
-
|
8
|
+
let otherUserLatitude = value?["userLatitude"] as? String
|
9
|
+
print("ユーザー緯度:", otherUserLatitude)
|
10
|
+
})
|
11
|
+
}
|
12
|
+
```
|
5
13
|
|
14
|
+
あるべきはsetValue時に
|
6
|
-
|
15
|
+
```
|
16
|
+
let userCoordinate = ["userLatitude": latitude.text]
|
17
|
+
ref.child("users").child(user!).setValue(["userCoordinate": userCoordinate])
|
18
|
+
```
|
19
|
+
取得するときは
|
20
|
+
```
|
7
|
-
ref.child(user!).child("
|
21
|
+
ref.child("users").child(user!).child("userCoordinate")...
|
8
22
|
```
|