回答編集履歴
1
質問を間違って解釈してしまったため修正
answer
CHANGED
@@ -1,7 +1,24 @@
|
|
1
1
|
以下の方法で取れますよ。
|
2
2
|
```ここに言語を入力
|
3
|
-
let reference = Database.database().
|
3
|
+
let reference = Database.database().reference().child("hoge")
|
4
4
|
//以下で自動生成された値をとる
|
5
5
|
let childAutoIdKey = reference.childByAutoId()
|
6
6
|
print("これが自動生成された値", childAutoIdKey)
|
7
|
+
```
|
8
|
+
|
9
|
+
修正:
|
10
|
+
Firebase realtimedatabaseのobserveメソッドを使って値を取得
|
11
|
+
```ここに言語を入力
|
12
|
+
let reference = Database.database().reference().child("quizs")
|
13
|
+
reference.observeSingleEvent(of: .value, with: { (snapshot) in
|
14
|
+
guard let dictionary = snapshot.value as? [String: Any] else {return}
|
15
|
+
dictionary.forEach { (autokey, userInfo) in
|
16
|
+
print("これが自動生成ID", autoKey)
|
17
|
+
}
|
18
|
+
|
19
|
+
}) { (err) in
|
20
|
+
print("エラーが起きました", err.localizedDescription)
|
21
|
+
return
|
22
|
+
}
|
23
|
+
|
7
24
|
```
|