Realm 中没有 addNotificationBlock 方法。它在哪里?

Tim*_*Tim 4 notifications realm swift

我正在尝试.addNotificationBlock在 Swift Realm 中使用方法。我有其他方法,但实际上不是这个(看图像)。为什么?

let realm = RealmService.shared.realm
racks = realm.objects(Rack.self)

notificationToken = realm.??? { (notification, realm) in
    self.tableView.reloadData()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Epi*_*rce 5

3.0.0 发行说明 (2017-10-16)

重大变化

旧 API 新 API

NotificationToken.stop()NotificationToken.invalidate()

-[RLMNotificationToken 停止] -[RLMNotificationToken 无效]

RealmCollection.addNotificationBlock( :) RealmCollection.observe( :)

尝试observe


Mar*_*hex 5

斯威夫特 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()

Run Code Online (Sandbox Code Playgroud)