質問編集履歴

2

コードの修正

2020/09/12 01:44

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -106,7 +106,7 @@
106
106
 
107
107
  override func viewDidLoad() {
108
108
 
109
- //nameLabel.text = String(passedUserName)
109
+ nameLabel.text = String(passedUserName)
110
110
 
111
111
  print(passedUserName)
112
112
 

1

修正後のコードの追加

2020/09/12 01:44

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Firestoreによるデータの表示がうまくいきません
1
+ ううFirestoreによるデータの表示がうまくいきません
test CHANGED
@@ -64,6 +64,188 @@
64
64
 
65
65
 
66
66
 
67
+
68
+
69
+
70
+
71
+
72
+
73
+ DetailViewController.swift
74
+
75
+ ```ここに言語を入力
76
+
77
+ import UIKit
78
+
79
+ import NCMB
80
+
81
+ import SCLAlertView
82
+
83
+ import FirebaseFirestore
84
+
85
+ import FirebaseAuth
86
+
87
+ import FirebaseStorage
88
+
89
+
90
+
91
+ class DetailViewController: UIViewController, UITextViewDelegate {
92
+
93
+
94
+
95
+
96
+
97
+ @IBOutlet var nameLabel: UILabel!
98
+
99
+ var passedUserName = String()
100
+
101
+ var passedUserId = String()
102
+
103
+
104
+
105
+
106
+
107
+ override func viewDidLoad() {
108
+
109
+ //nameLabel.text = String(passedUserName)
110
+
111
+ print(passedUserName)
112
+
113
+ print(passedUserId)
114
+
115
+
116
+
117
+ let db = Firestore.firestore()
118
+
119
+
120
+
121
+ db.collection("users").getDocuments() { (querySnapshot, error) in
122
+
123
+ if let error = error {
124
+
125
+ print(error)
126
+
127
+ } else {
128
+
129
+ for document in querySnapshot!.documents {
130
+
131
+
132
+
133
+ if document.documentID == self.passedUserId{
134
+
135
+ print("yayayaya")
136
+
137
+ print(self.passedUserId)
138
+
139
+ }else{
140
+
141
+ print(self.passedUserId)
142
+
143
+ print("nononono")
144
+
145
+ }
146
+
147
+ print("(document.documentID) => (document.data())")
148
+
149
+ }
150
+
151
+ }
152
+
153
+ }
154
+
155
+
156
+
157
+
158
+
159
+ /*
160
+
161
+ let document = db.collection("users")
162
+
163
+ document.getDocuments { (snapshot, error) in
164
+
165
+ if error != nil{
166
+
167
+ print(error)
168
+
169
+ }else{
170
+
171
+ print(snapshot?.documents)
172
+
173
+ }
174
+
175
+ }
176
+
177
+ */
178
+
179
+
180
+
181
+ /*
182
+
183
+ let document = db.collection("users").document(passedUserId)
184
+
185
+ document.getDocument { (snapshot, error) in
186
+
187
+ if error != nil {
188
+
189
+ print(error)
190
+
191
+ }else{
192
+
193
+ print("ああああああああ")
194
+
195
+ }
196
+
197
+ }
198
+
199
+ */
200
+
201
+
202
+
203
+
204
+
205
+ }
206
+
207
+
208
+
209
+ override func viewWillAppear(_ animated: Bool) {
210
+
211
+ nameLabel.text = passedUserName
212
+
213
+ }
214
+
215
+
216
+
217
+
218
+
219
+ func loadDetail(){
220
+
221
+
222
+
223
+ }
224
+
225
+ }
226
+
227
+ ```
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ 修正後
248
+
67
249
  SearchViewController.swift
68
250
 
69
251
  ```ここに言語を入力
@@ -106,10 +288,20 @@
106
288
 
107
289
 
108
290
 
291
+
292
+
109
-
293
+ var yay = ["月曜日", "火曜日", "水曜日"]
294
+
295
+
296
+
297
+
298
+
299
+
110
300
 
111
301
  override func viewDidLoad() {
112
302
 
303
+ super.viewDidLoad()
304
+
113
305
  print("1")
114
306
 
115
307
  searchUserTableView.dataSource = self
@@ -134,7 +326,7 @@
134
326
 
135
327
  override func viewWillAppear(_ animated: Bool) {
136
328
 
137
-
329
+ super.viewWillAppear(animated)
138
330
 
139
331
  }
140
332
 
@@ -254,6 +446,28 @@
254
446
 
255
447
 
256
448
 
449
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
450
+
451
+ if segue.identifier == "toDetail"{
452
+
453
+ let detailViewController = segue.destination as! DetailViewController
454
+
455
+ detailViewController.passedUserName = selectedUser
456
+
457
+ detailViewController.passedUserId = selectedUserId
458
+
459
+
460
+
461
+ print("11111")
462
+
463
+ }
464
+
465
+ }
466
+
467
+
468
+
469
+
470
+
257
471
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
258
472
 
259
473
  let selectedUser = allUsers[indexPath.row]
@@ -270,184 +484,18 @@
270
484
 
271
485
  print(selectedUserId)
272
486
 
487
+
488
+
489
+ print("222222")
490
+
491
+ performSegue(withIdentifier: "toDetail", sender: nil)
492
+
493
+ print("333333")
494
+
273
495
  tableView.deselectRow(at: indexPath, animated: true)
274
496
 
497
+ print("444444")
498
+
275
- }
499
+ }
276
-
277
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
278
-
279
- if segue.identifier == "toDetail"{
280
-
281
- let detailViewController = segue.destination as! DetailViewController
282
-
283
- detailViewController.passedUserName = selectedUser
284
-
285
- detailViewController.passedUserId = selectedUserId
286
-
287
- }
288
-
289
- }
290
-
291
- }
292
500
 
293
501
  ```
294
-
295
-
296
-
297
-
298
-
299
- DetailViewController.swift
300
-
301
- ```ここに言語を入力
302
-
303
- import UIKit
304
-
305
- import NCMB
306
-
307
- import SCLAlertView
308
-
309
- import FirebaseFirestore
310
-
311
- import FirebaseAuth
312
-
313
- import FirebaseStorage
314
-
315
-
316
-
317
- class DetailViewController: UIViewController, UITextViewDelegate {
318
-
319
-
320
-
321
-
322
-
323
- @IBOutlet var nameLabel: UILabel!
324
-
325
- var passedUserName = String()
326
-
327
- var passedUserId = String()
328
-
329
-
330
-
331
-
332
-
333
- override func viewDidLoad() {
334
-
335
- //nameLabel.text = String(passedUserName)
336
-
337
- print(passedUserName)
338
-
339
- print(passedUserId)
340
-
341
-
342
-
343
- let db = Firestore.firestore()
344
-
345
-
346
-
347
- db.collection("users").getDocuments() { (querySnapshot, error) in
348
-
349
- if let error = error {
350
-
351
- print(error)
352
-
353
- } else {
354
-
355
- for document in querySnapshot!.documents {
356
-
357
-
358
-
359
- if document.documentID == self.passedUserId{
360
-
361
- print("yayayaya")
362
-
363
- print(self.passedUserId)
364
-
365
- }else{
366
-
367
- print(self.passedUserId)
368
-
369
- print("nononono")
370
-
371
- }
372
-
373
- print("(document.documentID) => (document.data())")
374
-
375
- }
376
-
377
- }
378
-
379
- }
380
-
381
-
382
-
383
-
384
-
385
- /*
386
-
387
- let document = db.collection("users")
388
-
389
- document.getDocuments { (snapshot, error) in
390
-
391
- if error != nil{
392
-
393
- print(error)
394
-
395
- }else{
396
-
397
- print(snapshot?.documents)
398
-
399
- }
400
-
401
- }
402
-
403
- */
404
-
405
-
406
-
407
- /*
408
-
409
- let document = db.collection("users").document(passedUserId)
410
-
411
- document.getDocument { (snapshot, error) in
412
-
413
- if error != nil {
414
-
415
- print(error)
416
-
417
- }else{
418
-
419
- print("ああああああああ")
420
-
421
- }
422
-
423
- }
424
-
425
- */
426
-
427
-
428
-
429
-
430
-
431
- }
432
-
433
-
434
-
435
- override func viewWillAppear(_ animated: Bool) {
436
-
437
- nameLabel.text = passedUserName
438
-
439
- }
440
-
441
-
442
-
443
-
444
-
445
- func loadDetail(){
446
-
447
-
448
-
449
- }
450
-
451
- }
452
-
453
- ```