0
그래서 다른 셀이 변경되면 자동으로 리프레시하는 표 셀을 갖기 위해 노력하고 있습니다. 내 코드가 테이블 배열 내에서 객체를 찾고, 값을 변경하고, 테이블보기를 새로 고칠 수 있기를 기대했지만, 어떤 이유로 배열이 업데이트 되더라도 테이블이 즉시 업데이트를 거부합니다. 내 새 값을 보려면 앱을 다시 시작하거나보기를 다시 열어야합니다.Firebase 데이터 변경시 UITableView 업데이트
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")
}
})
}
지수 (withName : 문자열, 연락처 : 연락처) 메소드를 ContactManager에 :
이것은 내가 지금까지 뭘 오전입니다
//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
}
}
}
메인 스레드에서 'self.tableView.reloadData();'를 호출해야합니다. –