Search code examples
swiftrealmios11

How we retrieve data from realm locally in UITableView?


I downloaded all data in local db. I want that when internet is not available the local is retrieve automatically.

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

Solution

  • Check this one its working fine

    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()
    }