ios - Realm token 有什么用?

标签 ios realm

初始化 Realm 通知时,需要设置 token:

// Observe Realm Notifications
__weak typeof(self) weakSelf = self;
RLMRealm *realm = [RLMRealm defaultRealm];
self.token = [realm addNotificationBlock:^(NSString *note, RLMRealm * realm) {
    [weakSelf updateUI];
}];

我不是 100% 清楚这有什么好处。是为了保留对 self 的引用吗?

最佳答案

我找到了可能的答案:需要 token 才能从 View 中删除通知。通知中似乎没有提及它。

关于ios - Realm token 有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31132757/

相关文章:

Android Studio 4.1 数据库检查器不显示 Realm 数据库

swift - 使用 ObjectMapper 从转换器获取子 RLMObjects

ios - Swift 3.0 的 Realm 支持

ios - 存储不同 NSData 时 Realm 文件大小差异过大

ios - 如何在 iOS 上嵌入 Facebook 共享,如附图所示

ios - calloutAccessoryControlTapped 后的空白 ViewController

iphone - iOS:一个动画之后,所有其他 View 开始动画

ios - 使用 Facebook Graph api v2.0 苦苦挣扎的新 iOS 应用

ios - 从 UIColor 创建 UIImage 以用作 UIButton 的背景图像

swift - 如何为 Realm 构建查询对象