[英]reloadData() doesn't update parent TableView
I have a custom TableViewController
called LibraryTableViewController
. 我有一个名为LibraryTableViewController
的自定义TableViewController
。
class LibraryTableViewController: UITableViewController {
contains this data for rendering. 包含要渲染的数据。
var items: [item] = [] var个项目:[item] = []
Then, I have another class for Firebase that inherits the LibraryTableViewController
as a delegate. 然后,我有了Firebase的另一个类,该类继承了LibraryTableViewController
作为委托。 (I am not sure if this is the right description.) (我不确定这是否是正确的描述。)
class FirebaseDB : LibraryTableViewController {
Then, I have a global instance of FirebaseDB as 然后,我有一个FirebaseDB全局实例
let database = FirebaseDB() 让数据库= FirebaseDB()
I have an observer listening to the changes in the database in the Firebase class, and I was updating 我有一个观察者正在侦听Firebase类中数据库中的更改,并且我正在更新
self.items 自我项目
Then, trying to refresh the LibraryTableViewController
using 然后,尝试使用以下命令刷新LibraryTableViewController
self.tableView.reloadData() self.tableView.reloadData()
I might be wrong in understanding my current problem. 在理解我当前的问题时,我可能是错的。 What I think is that the items array that I am updating isn't the same instance as the tableView
that I see on the app. 我认为我要更新的items数组与我在应用程序上看到的tableView
实例不同。 It is updating the FirebaseDB instance database's items which isn't being rendered on the app. 它正在更新FirebaseDB实例数据库中未在应用程序上呈现的项目。 How do I make sure that the right instance is being updated? 如何确保正确的实例正在更新?
a lot of code missing but you can check: 很多代码丢失,但是您可以检查:
but better give us more code) 但最好给我们更多代码)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.