我们如何在 UITableView 中从本地领域检索数据?

How we retrieve data from realm locally in UITableView?

我下载了本地数据库中的所有数据。我希望当互联网不可用时自动检索本地。

for result in data {
self.dataSource.append(ModelData(value: result))
}
try! Global.APP_REALM?.write(){
Global.APP_REALM?.add(self.dataSource, update: true)
}

检查这个是否工作正常

if !Connectivity.isConnectedToInternet() {
dataSource.removeAll()
let Object = Global.APP_REALM?.objects(Hameotology.self)
                for result in hameotologyObject! {
                    self.dataSource.append(ModelData(value: result))
                }
                tableViewTest.reloadData()
}