So versuche ich Tabellenzellen, die automatisch aktualisieren, wenn eine andere der Zellen geändert werden. Ich hoffte, dass mein Code das Objekt innerhalb des Tabellenarrays finden, einen Wert ändern und die Tabellenansicht auf einen Schlag aktualisieren konnte, aber aus irgendeinem Grund, obwohl mein Array aktualisiert wird, verweigert die Tabelle die sofortige Aktualisierung. Um meine neuen Werte zu sehen, muss ich die App neu starten oder die Ansicht erneut öffnen. DieseAktualisieren einer UITableView auf Firebase Daten ändern
ist, was ich tue so weit:
usersRef.queryOrdered(byChild "contactList/(currentUID!)").queryEqual(toValue: true).observe(.childChanged, with: { (snapshot) in
if let friends = snapshot.value as? [String: AnyObject] {
//Making a new updated contact
let name = friends["name"] as! String
print(name)
let edit = Contact()
edit.name = name;
edit.isSafe = friends["isSafe"] as! Bool
edit.email = friends["email"] as! String
//My manager object has a custom array objects called contacts.
self.manager.index(withName: name, contact: edit)
self.tableView.reloadData();
} else {
print("Failed to Convert")
}
})
}
Index (withname: String, Kontakt: Kontakt) -Methode in dem Kontaktmanager:
//This method goes through the contactList to check names to see which contact has a specific name equal to "name", then it uses the "contact" to update that specific child.
public mutating func index(withName: String, contact: Contact) {
for iterator in 0 ..< contactList.count {
if (contactList[iterator].name == withName) {
contactList[iterator] = contact
}
}
}
'selb.tableView.ReloadData();' sollte im Haupt-Thread aufgerufen werden –