質問編集履歴
6
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
class usersViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
|
23
|
-
|
23
|
+
{
|
24
24
|
|
25
25
|
|
26
26
|
@IBOutlet weak var tableView: UITableView!
|
@@ -35,9 +35,14 @@
|
|
35
35
|
tableView.delegate = self
|
36
36
|
tableView.dataSource = self
|
37
37
|
|
38
|
+
|
39
|
+
|
40
|
+
}
|
41
|
+
|
42
|
+
func users(){
|
38
43
|
ref.child("Users").observeSingleEvent(of: .value, with: { (snapshot) in
|
39
44
|
// Get user value
|
40
|
-
|
45
|
+
|
41
46
|
let value = snapshot.value as? [String:NSDictionary]
|
42
47
|
|
43
48
|
for key in value!.keys.sorted() {
|
@@ -46,28 +51,27 @@
|
|
46
51
|
let snap = value![key]
|
47
52
|
if let roomname = snap!["名前"] as? String {
|
48
53
|
self.roomArray.append(roomname)}
|
49
|
-
|
54
|
+
}
|
50
|
-
|
51
|
-
|
52
55
|
}
|
53
|
-
|
56
|
+
)}
|
54
57
|
|
58
|
+
|
55
59
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
56
60
|
return roomArray.count
|
57
61
|
}
|
58
62
|
|
59
63
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
60
|
-
|
64
|
+
|
61
65
|
let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "date", for: indexPath)
|
62
66
|
|
63
67
|
|
64
68
|
cell.textLabel?.text = roomArray[indexPath.row]
|
65
69
|
|
66
70
|
|
67
|
-
|
71
|
+
return cell
|
68
72
|
|
69
73
|
}
|
70
|
-
|
74
|
+
|
71
75
|
}
|
72
76
|
|
73
77
|
|
5
誤字
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
swift firebaseのデータをテーブルに
|
1
|
+
swift firebaseのデータ配列をテーブルに入れたい
|
body
CHANGED
File without changes
|
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -40,31 +40,15 @@
|
|
40
40
|
|
41
41
|
let value = snapshot.value as? [String:NSDictionary]
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
43
|
for key in value!.keys.sorted() {
|
48
44
|
//snap : 階層下のデータを書くのすいた辞書
|
49
45
|
//今回なら、snap = ["RoomName":"はわはわ"]
|
50
46
|
let snap = value![key]
|
51
47
|
if let roomname = snap!["名前"] as? String {
|
52
48
|
self.roomArray.append(roomname)}
|
53
|
-
|
54
|
-
|
55
49
|
}
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
|
59
|
-
print(names)
|
60
|
-
}
|
61
|
-
|
62
51
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
52
|
}
|
69
53
|
)}
|
70
54
|
|
@@ -83,15 +67,10 @@
|
|
83
67
|
return cell
|
84
68
|
|
85
69
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
70
|
+
|
89
71
|
}
|
90
72
|
|
91
73
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
74
|
```
|
96
75
|
|
97
76
|
|
3
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#やってみたこと
|
12
12
|
|
13
13
|
```ここに言語を入力
|
14
|
-
|
14
|
+
import UIKit
|
15
15
|
import Firebase
|
16
16
|
import FirebaseDatabase
|
17
17
|
import FirebaseAuth
|
2
syuusei
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,22 +11,87 @@
|
|
11
11
|
#やってみたこと
|
12
12
|
|
13
13
|
```ここに言語を入力
|
14
|
+
limport UIKit
|
15
|
+
import Firebase
|
14
|
-
|
16
|
+
import FirebaseDatabase
|
17
|
+
import FirebaseAuth
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
class usersViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
|
23
|
+
{
|
15
24
|
|
16
|
-
|
25
|
+
|
17
|
-
|
26
|
+
@IBOutlet weak var tableView: UITableView!
|
27
|
+
|
18
|
-
|
28
|
+
let ref = Database.database().reference()
|
29
|
+
var roomArray = [String]()
|
30
|
+
|
31
|
+
|
32
|
+
override func viewDidLoad() {
|
33
|
+
super.viewDidLoad()
|
19
34
|
|
35
|
+
tableView.delegate = self
|
20
|
-
|
36
|
+
tableView.dataSource = self
|
21
37
|
|
38
|
+
ref.child("Users").observeSingleEvent(of: .value, with: { (snapshot) in
|
39
|
+
// Get user value
|
40
|
+
|
41
|
+
let value = snapshot.value as? [String:NSDictionary]
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
22
|
-
|
47
|
+
for key in value!.keys.sorted() {
|
48
|
+
//snap : 階層下のデータを書くのすいた辞書
|
49
|
+
//今回なら、snap = ["RoomName":"はわはわ"]
|
23
|
-
|
50
|
+
let snap = value![key]
|
24
|
-
|
51
|
+
if let roomname = snap!["名前"] as? String {
|
25
|
-
|
52
|
+
self.roomArray.append(roomname)}
|
53
|
+
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
for names in self.roomArray{
|
59
|
+
print(names)
|
26
60
|
}
|
61
|
+
|
27
62
|
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
}
|
69
|
+
)}
|
70
|
+
|
71
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
28
|
-
|
72
|
+
return roomArray.count
|
73
|
+
}
|
74
|
+
|
75
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
76
|
+
|
77
|
+
let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "date", for: indexPath)
|
78
|
+
|
79
|
+
|
80
|
+
cell.textLabel?.text = roomArray[indexPath.row]
|
81
|
+
|
82
|
+
|
29
|
-
|
83
|
+
return cell
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
30
95
|
```
|
31
96
|
|
32
97
|
|
1
修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
swift firebaseのデータをテーブルに入れ
|
1
|
+
swift firebaseのデータをテーブルに配列で入れたい
|
body
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
|
6
|
-
|
6
|
+
名前を一つずつ入れたい場合どのようにすればいいのでしょうか?
|
7
7
|
現状の保存データはこんな感じです。
|
8
8
|

|
9
9
|
|
@@ -20,22 +20,14 @@
|
|
20
20
|
var roomArray = [String]()
|
21
21
|
|
22
22
|
for key in value!.keys.sorted() {
|
23
|
-
//snap : 階層下のデータを書くのすいた辞書
|
24
|
-
//今回なら、snap = ["RoomName":"はわはわ"]
|
25
23
|
let snap = value![key]
|
26
24
|
if let roomname = snap!["名前"] as? String {
|
27
|
-
roomArray.append(roomname)
|
25
|
+
roomArray.append(roomname)}
|
28
26
|
}
|
27
|
+
|
29
28
|
for names in roomArray{
|
30
|
-
print(names)
|
29
|
+
print(names)}
|
31
|
-
}
|
32
30
|
```
|
33
31
|
|
32
|
+
|
34
|
-
|
33
|
+
配列の取り出しはできたのですが、テーブルに表示したいです
|
35
|
-
ss
|
36
|
-
ss
|
37
|
-
aaaaa
|
38
|
-
ss
|
39
|
-
aaaaa
|
40
|
-
abc
|
41
|
-
と出力されます。
|