TableViewController not updating cells

后端 未结 2 1978
既然无缘
既然无缘 2021-01-26 11:12

This app allows Rider to request a ride and driver to accept the request. In this tableview are the rides the riders (2) have requested.

Unable to update tableviewcel

2条回答
  •  借酒劲吻你
    2021-01-26 12:04

    make sure you reload tableview in main queue in with parameter closure.

    ref.child("drivers").child("RideRequests").observe(FIRDataEventType.value, with: { snapshot in
        self.rideRequests.removeAll()
        for item in snapshot.children{
            self.rideRequests.append(item as! FIRDataSnapshot)
        }
        self.rideRequests.reverse()
        DispatchQueue.main.async (execute: { () -> Void in
            self.tableView.reloadData()
        })
    })
    

提交回复
热议问题