質問編集履歴
6
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
|
43
43
|
class usersViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
|
44
44
|
|
45
|
-
|
45
|
+
{
|
46
46
|
|
47
47
|
|
48
48
|
|
@@ -72,11 +72,21 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
func users(){
|
84
|
+
|
75
85
|
ref.child("Users").observeSingleEvent(of: .value, with: { (snapshot) in
|
76
86
|
|
77
87
|
// Get user value
|
78
88
|
|
79
|
-
|
89
|
+
|
80
90
|
|
81
91
|
let value = snapshot.value as? [String:NSDictionary]
|
82
92
|
|
@@ -94,15 +104,13 @@
|
|
94
104
|
|
95
105
|
self.roomArray.append(roomname)}
|
96
106
|
|
97
|
-
|
107
|
+
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
108
|
|
103
109
|
}
|
104
110
|
|
105
|
-
)}
|
111
|
+
)}
|
112
|
+
|
113
|
+
|
106
114
|
|
107
115
|
|
108
116
|
|
@@ -116,7 +124,7 @@
|
|
116
124
|
|
117
125
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
118
126
|
|
119
|
-
|
127
|
+
|
120
128
|
|
121
129
|
let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "date", for: indexPath)
|
122
130
|
|
@@ -130,13 +138,13 @@
|
|
130
138
|
|
131
139
|
|
132
140
|
|
133
|
-
|
141
|
+
return cell
|
134
142
|
|
135
143
|
|
136
144
|
|
137
145
|
}
|
138
146
|
|
139
|
-
|
147
|
+
|
140
148
|
|
141
149
|
}
|
142
150
|
|
5
誤字
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
swift firebaseのデータをテーブルに
|
1
|
+
swift firebaseのデータ配列をテーブルに入れたい
|
test
CHANGED
File without changes
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,14 +82,6 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
85
|
for key in value!.keys.sorted() {
|
94
86
|
|
95
87
|
//snap : 階層下のデータを書くのすいた辞書
|
@@ -102,33 +94,9 @@
|
|
102
94
|
|
103
95
|
self.roomArray.append(roomname)}
|
104
96
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
97
|
}
|
110
98
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
99
|
+
|
116
|
-
|
117
|
-
print(names)
|
118
|
-
|
119
|
-
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
100
|
|
133
101
|
|
134
102
|
|
@@ -168,19 +136,9 @@
|
|
168
136
|
|
169
137
|
}
|
170
138
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
139
|
+
|
176
140
|
|
177
141
|
}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
142
|
|
185
143
|
|
186
144
|
|
3
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
```ここに言語を入力
|
26
26
|
|
27
|
-
|
27
|
+
import UIKit
|
28
28
|
|
29
29
|
import Firebase
|
30
30
|
|
2
syuusei
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,37 +24,167 @@
|
|
24
24
|
|
25
25
|
```ここに言語を入力
|
26
26
|
|
27
|
+
limport UIKit
|
28
|
+
|
29
|
+
import Firebase
|
30
|
+
|
27
|
-
|
31
|
+
import FirebaseDatabase
|
32
|
+
|
33
|
+
import FirebaseAuth
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class usersViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
|
44
|
+
|
45
|
+
{
|
28
46
|
|
29
47
|
|
30
48
|
|
31
|
-
|
49
|
+
|
32
50
|
|
33
|
-
|
51
|
+
@IBOutlet weak var tableView: UITableView!
|
34
52
|
|
53
|
+
|
54
|
+
|
35
|
-
|
55
|
+
let ref = Database.database().reference()
|
56
|
+
|
57
|
+
var roomArray = [String]()
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
override func viewDidLoad() {
|
64
|
+
|
65
|
+
super.viewDidLoad()
|
36
66
|
|
37
67
|
|
38
68
|
|
69
|
+
tableView.delegate = self
|
70
|
+
|
39
|
-
|
71
|
+
tableView.dataSource = self
|
40
72
|
|
41
73
|
|
42
74
|
|
43
|
-
for
|
75
|
+
ref.child("Users").observeSingleEvent(of: .value, with: { (snapshot) in
|
44
76
|
|
45
|
-
|
77
|
+
// Get user value
|
46
78
|
|
47
|
-
|
79
|
+
|
48
80
|
|
81
|
+
let value = snapshot.value as? [String:NSDictionary]
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
for key in value!.keys.sorted() {
|
94
|
+
|
95
|
+
//snap : 階層下のデータを書くのすいた辞書
|
96
|
+
|
97
|
+
//今回なら、snap = ["RoomName":"はわはわ"]
|
98
|
+
|
99
|
+
let snap = value![key]
|
100
|
+
|
101
|
+
if let roomname = snap!["名前"] as? String {
|
102
|
+
|
49
|
-
roomArray.append(roomname)}
|
103
|
+
self.roomArray.append(roomname)}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
for names in self.roomArray{
|
116
|
+
|
117
|
+
print(names)
|
50
118
|
|
51
119
|
}
|
52
120
|
|
121
|
+
|
53
122
|
|
54
123
|
|
55
|
-
for names in roomArray{
|
56
124
|
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
)}
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
142
|
+
|
143
|
+
return roomArray.count
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "date", for: indexPath)
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
cell.textLabel?.text = roomArray[indexPath.row]
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
57
|
-
|
165
|
+
return cell
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
58
188
|
|
59
189
|
```
|
60
190
|
|
1
修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
swift firebaseのデータをテーブルに入れ
|
1
|
+
swift firebaseのデータをテーブルに配列で入れたい
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
名前を一つずつ入れたい場合どのようにすればいいのでしょうか?
|
12
12
|
|
13
13
|
現状の保存データはこんな感じです。
|
14
14
|
|
@@ -42,40 +42,24 @@
|
|
42
42
|
|
43
43
|
for key in value!.keys.sorted() {
|
44
44
|
|
45
|
-
//snap : 階層下のデータを書くのすいた辞書
|
46
|
-
|
47
|
-
//今回なら、snap = ["RoomName":"はわはわ"]
|
48
|
-
|
49
45
|
let snap = value![key]
|
50
46
|
|
51
47
|
if let roomname = snap!["名前"] as? String {
|
52
48
|
|
53
|
-
roomArray.append(roomname)
|
49
|
+
roomArray.append(roomname)}
|
54
50
|
|
55
51
|
}
|
56
52
|
|
53
|
+
|
54
|
+
|
57
55
|
for names in roomArray{
|
58
56
|
|
59
|
-
print(names)
|
57
|
+
print(names)}
|
60
|
-
|
61
|
-
}
|
62
58
|
|
63
59
|
```
|
64
60
|
|
65
61
|
|
66
62
|
|
67
|
-
このように書くと
|
68
63
|
|
69
|
-
ss
|
70
64
|
|
71
|
-
ss
|
72
|
-
|
73
|
-
aaaaa
|
74
|
-
|
75
|
-
ss
|
76
|
-
|
77
|
-
aaaaa
|
78
|
-
|
79
|
-
abc
|
80
|
-
|
81
|
-
|
65
|
+
配列の取り出しはできたのですが、テーブルに表示したいです
|