I heard that I should always do user interface work on the main thread while reading data from Firebase.
I tried to do self.tableView.reloadData on the background thread inside a Firebase observe(.value) function and the app did not crash or freeze.
databaseReference.observe(.value) { [weak self] snapshot in
guard let self = self else { return }
self.tableView.reloadData()
}
I tried to do the same work inside getData function instead of observe(.value) function and the app crashed.
databaseReference.getData { [weak self] error, snapshot in
guard let self = self else { return }
self.tableView.reloadData()
}
So why the app crashed inside getData function and it did not crash inside observe(.value) function?
