1
I’m using a custom table that retrieves data from Firebase
. But it only updates, new data, if I close the app and open again, even if entering the reloadData()
on the table.
Example: The table is without any element, when a new element is added by another Viewcontroller, I go back to check the table, and this new element appears.
When the second element is added, the table appears duplicated (twice this second element), but if I check in Firebase, os nós
are not duplicated.
So I need to close the application, and right away with it open the elements are updated in the table, it is as if the reloadData
was not being recharging.
What I need to do or what I’m doing wrong?
func exibeAtrasado(){
tvAtrasados.register(UINib(nibName: "OnAtrasados", bundle: nil), forCellReuseIdentifier: "OnAtrasados")
let database = Database.database().reference().child("OAtrasado")
database.observe(DataEventType.value) { (snapshot) in
if snapshot.childrenCount > 0 {
for onAtrasado in snapshot.children.allObjects as! [DataSnapshot] {
let onsObject = onAtrasado.value as? [String: AnyObject]
let data = onsObject?["data"]
let horario = onsObject?["horário"]
let linha = onsObject?["linha"]
let onibAtr = ConfiguracaoOnAtrasados(horario: horario as! String, linha: linha as! String, data: data as! String)
self.onb.append(onibAtr)
}
self.tvAtrasados.reloadData()
}