質問編集履歴
2
コードの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
override func viewDidLoad() {
|
55
|
-
|
55
|
+
nameLabel.text = String(passedUserName)
|
56
56
|
print(passedUserName)
|
57
57
|
print(passedUserId)
|
58
58
|
|
1
修正後のコードの追加
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Firestoreによるデータの表示がうまくいきません
|
1
|
+
ううFirestoreによるデータの表示がうまくいきません
|
body
CHANGED
@@ -31,6 +31,97 @@
|
|
31
31
|
|
32
32
|
画面遷移はSearchViewController.swift→DetailViewController.swiftです
|
33
33
|
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
DetailViewController.swift
|
38
|
+
```ここに言語を入力
|
39
|
+
import UIKit
|
40
|
+
import NCMB
|
41
|
+
import SCLAlertView
|
42
|
+
import FirebaseFirestore
|
43
|
+
import FirebaseAuth
|
44
|
+
import FirebaseStorage
|
45
|
+
|
46
|
+
class DetailViewController: UIViewController, UITextViewDelegate {
|
47
|
+
|
48
|
+
|
49
|
+
@IBOutlet var nameLabel: UILabel!
|
50
|
+
var passedUserName = String()
|
51
|
+
var passedUserId = String()
|
52
|
+
|
53
|
+
|
54
|
+
override func viewDidLoad() {
|
55
|
+
//nameLabel.text = String(passedUserName)
|
56
|
+
print(passedUserName)
|
57
|
+
print(passedUserId)
|
58
|
+
|
59
|
+
let db = Firestore.firestore()
|
60
|
+
|
61
|
+
db.collection("users").getDocuments() { (querySnapshot, error) in
|
62
|
+
if let error = error {
|
63
|
+
print(error)
|
64
|
+
} else {
|
65
|
+
for document in querySnapshot!.documents {
|
66
|
+
|
67
|
+
if document.documentID == self.passedUserId{
|
68
|
+
print("yayayaya")
|
69
|
+
print(self.passedUserId)
|
70
|
+
}else{
|
71
|
+
print(self.passedUserId)
|
72
|
+
print("nononono")
|
73
|
+
}
|
74
|
+
print("(document.documentID) => (document.data())")
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
/*
|
81
|
+
let document = db.collection("users")
|
82
|
+
document.getDocuments { (snapshot, error) in
|
83
|
+
if error != nil{
|
84
|
+
print(error)
|
85
|
+
}else{
|
86
|
+
print(snapshot?.documents)
|
87
|
+
}
|
88
|
+
}
|
89
|
+
*/
|
90
|
+
|
91
|
+
/*
|
92
|
+
let document = db.collection("users").document(passedUserId)
|
93
|
+
document.getDocument { (snapshot, error) in
|
94
|
+
if error != nil {
|
95
|
+
print(error)
|
96
|
+
}else{
|
97
|
+
print("ああああああああ")
|
98
|
+
}
|
99
|
+
}
|
100
|
+
*/
|
101
|
+
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
override func viewWillAppear(_ animated: Bool) {
|
106
|
+
nameLabel.text = passedUserName
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
func loadDetail(){
|
111
|
+
|
112
|
+
}
|
113
|
+
}
|
114
|
+
```
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
修正後
|
34
125
|
SearchViewController.swift
|
35
126
|
```ここに言語を入力
|
36
127
|
import UIKit
|
@@ -52,8 +143,13 @@
|
|
52
143
|
|
53
144
|
let db = Firestore.firestore()
|
54
145
|
|
146
|
+
|
55
|
-
|
147
|
+
var yay = ["月曜日", "火曜日", "水曜日"]
|
148
|
+
|
149
|
+
|
150
|
+
|
56
151
|
override func viewDidLoad() {
|
152
|
+
super.viewDidLoad()
|
57
153
|
print("1")
|
58
154
|
searchUserTableView.dataSource = self
|
59
155
|
searchUserTableView.delegate = self
|
@@ -66,7 +162,7 @@
|
|
66
162
|
}
|
67
163
|
|
68
164
|
override func viewWillAppear(_ animated: Bool) {
|
69
|
-
|
165
|
+
super.viewWillAppear(animated)
|
70
166
|
}
|
71
167
|
|
72
168
|
func loadUsers(){
|
@@ -126,102 +222,30 @@
|
|
126
222
|
return cell
|
127
223
|
}
|
128
224
|
|
129
|
-
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
130
|
-
let selectedUser = allUsers[indexPath.row]
|
131
|
-
let selectedUserId = allUsersId[indexPath.row]
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
print(selectedUser)
|
136
|
-
print(selectedUserId)
|
137
|
-
tableView.deselectRow(at: indexPath, animated: true)
|
138
|
-
}
|
139
225
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
140
226
|
if segue.identifier == "toDetail"{
|
141
227
|
let detailViewController = segue.destination as! DetailViewController
|
142
228
|
detailViewController.passedUserName = selectedUser
|
143
229
|
detailViewController.passedUserId = selectedUserId
|
230
|
+
|
231
|
+
print("11111")
|
144
232
|
}
|
145
233
|
}
|
146
|
-
}
|
147
|
-
```
|
148
|
-
|
149
|
-
|
150
|
-
DetailViewController.swift
|
151
|
-
```ここに言語を入力
|
152
|
-
import UIKit
|
153
|
-
import NCMB
|
154
|
-
import SCLAlertView
|
155
|
-
import FirebaseFirestore
|
156
|
-
import FirebaseAuth
|
157
|
-
import FirebaseStorage
|
158
|
-
|
159
|
-
class DetailViewController: UIViewController, UITextViewDelegate {
|
160
|
-
|
161
|
-
|
162
|
-
@IBOutlet var nameLabel: UILabel!
|
163
|
-
var passedUserName = String()
|
164
|
-
var passedUserId = String()
|
165
234
|
|
166
235
|
|
236
|
+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
167
|
-
|
237
|
+
let selectedUser = allUsers[indexPath.row]
|
168
|
-
|
238
|
+
let selectedUserId = allUsersId[indexPath.row]
|
169
|
-
print(passedUserName)
|
170
|
-
print(passedUserId)
|
171
239
|
|
172
|
-
let db = Firestore.firestore()
|
173
240
|
|
174
|
-
db.collection("users").getDocuments() { (querySnapshot, error) in
|
175
|
-
if let error = error {
|
176
|
-
print(error)
|
177
|
-
} else {
|
178
|
-
for document in querySnapshot!.documents {
|
179
|
-
|
180
|
-
if document.documentID == self.passedUserId{
|
181
|
-
print("yayayaya")
|
182
|
-
print(self.passedUserId)
|
183
|
-
}else{
|
184
|
-
print(self.passedUserId)
|
185
|
-
print("nononono")
|
186
|
-
}
|
187
|
-
print("(document.documentID) => (document.data())")
|
188
|
-
}
|
189
|
-
}
|
190
|
-
}
|
191
|
-
|
192
|
-
|
193
|
-
/*
|
194
|
-
let document = db.collection("users")
|
195
|
-
document.getDocuments { (snapshot, error) in
|
196
|
-
if error != nil{
|
197
|
-
print(error)
|
198
|
-
}else{
|
199
|
-
print(snapshot?.documents)
|
200
|
-
}
|
201
|
-
}
|
202
|
-
*/
|
203
|
-
|
204
|
-
/*
|
205
|
-
let document = db.collection("users").document(passedUserId)
|
206
|
-
document.getDocument { (snapshot, error) in
|
207
|
-
if error != nil {
|
208
|
-
print(error)
|
209
|
-
}else{
|
210
|
-
print("ああああああああ")
|
211
|
-
}
|
212
|
-
}
|
213
|
-
*/
|
214
|
-
|
215
|
-
|
216
|
-
}
|
217
241
|
|
218
|
-
|
242
|
+
print(selectedUser)
|
219
|
-
|
243
|
+
print(selectedUserId)
|
220
|
-
}
|
221
|
-
|
222
|
-
|
223
|
-
func loadDetail(){
|
224
244
|
|
245
|
+
print("222222")
|
246
|
+
performSegue(withIdentifier: "toDetail", sender: nil)
|
247
|
+
print("333333")
|
248
|
+
tableView.deselectRow(at: indexPath, animated: true)
|
249
|
+
print("444444")
|
225
250
|
}
|
226
|
-
}
|
227
251
|
```
|