草庐IT

notificationRunLoop

全部标签

ios - 后台线程上的 Realm 通知 token

我试图在后台线程上获取Realm数据并添加一个通知block(iOS、Swift)。基本示例:funcinitNotificationToken(){DispatchQueue.global(qos:.background).async{letrealm=try!Realm()results=self.getRealmResults()notificationToken=results.addNotificationBlock{[weakself](changes:RealmCollectionChange)inswitchchanges{case.initial:self?.init