You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After 3 years of poverty and dispair, Realm Finally added Collection Changes Notifications. Basically they can observe weather a collection has inserted, updated, changed, moved etc...
letmyDog=Dog()
myDog.name ="Rex"
myDog.age =1
realm.add(myDog)
notificationToken = results.addNotificationBlock{[weak self](changes:RealmCollectionChange)in
guard let tableView =self?.tableView else{return}
switch changes {case.Initial:// Results are now populated and can be accessed without blocking the UI
tableView.reloadData()
break
case.Update(_,let deletions,let insertions,let modifications):// Query results have changed, so apply them to the UITableView
tableView.beginUpdates()
tableView.insertRowsAtIndexPaths(insertions.map{NSIndexPath(forRow: $0, inSection:0)},
withRowAnimation:.Automatic)
tableView.deleteRowsAtIndexPaths(deletions.map{NSIndexPath(forRow: $0, inSection:0)},
withRowAnimation:.Automatic)
tableView.reloadRowsAtIndexPaths(modifications.map{NSIndexPath(forRow: $0, inSection:0)},
withRowAnimation:.Automatic)
tableView.endUpdates()
break
case.Error(let error):// An error occurred while opening the Realm file on the background worker threadfatalError("\(error)")
break
}}
The text was updated successfully, but these errors were encountered:
After 3 years of poverty and dispair, Realm Finally added Collection Changes Notifications. Basically they can observe weather a collection has inserted, updated, changed, moved etc...
You can find more information here : https://realm.io/docs/swift/latest/#notifications
The text was updated successfully, but these errors were encountered: