I'm trying to use .addNotificationBlock
method in Swift Realm. I have other methods but not actually this one (look at the image). Why?
let realm = RealmService.shared.realm
racks = realm.objects(Rack.self)
notificationToken = realm.??? { (notification, realm) in
self.tableView.reloadData()
3.0.0 Release notes (2017-10-16)
Breaking Changes
Old API New API
NotificationToken.stop() NotificationToken.invalidate()
-[RLMNotificationToken stop] -[RLMNotificationToken invalidate]
RealmCollection.addNotificationBlock(:) RealmCollection.observe(:)
Try observe
?
Swift 5
//Refresh the tableView in Real time returning a notification token
notificationToken = realm.observe { (notification, realm) in
self.tableView.reloadData()
}
notificationToken.invalidate() // instead of stop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With