There is no method addNotificationBlock in Realm. Where is it?

Viewed 768

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

enter image description here

2 Answers

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

Related