I have tableView and refreshControl. I want that tableView's data reload only when I pull-to-refresh. I've made the function that reload data, but it works always.
Data reload after pull-to-refresh, but also observe update tableView. How to remove it? I want to make observe, reload data and remove observe (remove connection).
func reloadTable() {
let ref = Database.database().reference()
let userID = Auth.auth().currentUser?.uid
postData.removeAll()
var databaseHandle: DatabaseHandle?
databaseHandle = ref.child("doctors").child(userID!).observe(.childAdded) {
(snapshot) in
if let actualPost = snapshot.value as? String {
self.postData.append(actualPost)
self.table.reloadData()
}
}
// I tried this:
ref.removeAllObservers()
// And this as well:
ref.removeObserver(withHandle: databaseHandle)
}
You need
let current = ref.child("doctors").child(userID!)
current.observe ///
current.removeAllObservers()
if you need to removeObservers you need to go deep as you add childs , as removeAllObservers
for parents doesn't remove them for childs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With