print文でしっかりとticketdata: 2 と表示されているのですがtableViewに反映されていません
どのようにしたらよいのでしょうか?
Swift
1 var ticketListener: ListenerRegistration? 2 3 var ticketData: [Ticket] = [] 4 5 func startListeningForTickets() { 6 7 let basicQuery = db.tickets.whereField("shopID", isEqualTo: userID) 8 9 ticketListener = basicQuery.addSnapshotListener({ (snapshot, error) in 10 if let error = error { 11 print("ホームビューコントローラーにてチケットのデータ取得失敗: ", error) 12 return 13 } 14 guard let snapshot = snapshot else { return } 15 self.ticketData = [] 16 for ticketDocument in snapshot.documents { 17 if let newTicket = Ticket(document: ticketDocument) { 18 self.ticketData.append(newTicket) 19 } 20 } 21 print("ticketdata: ",self.ticketData.count) 22 23 self.tableView.reloadData() 24 }) 25 } 26 27 28 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 29 return ticketData.count 30 } 31 32 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 33 34 let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 35 cell.backgroundColor = .red 36 return cell 37 } 38
cellにticketDataの内容を設定している部分が見当たりません。
回答1件
あなたの回答
tips
プレビュー