OGeek|极客世界-中国程序员成长平台

标题: ios - Realm token 有什么用? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 15:41
标题: ios - Realm token 有什么用?

初始化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的引用吗?



Best Answer-推荐答案


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

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






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4