ios - 警告 : RLMNotificationToken released without unregistering

标签 ios realm

我在 UITableView 的上下文中使用 RLM 通知,UITableView 是带有 UIPageViewDelegate 的 UIViewController 的 subview 。 ViewController 是动态创建的,在滑动到下一个 ViewController 后被销毁。但总是可以向后滑动一页。因此,我无法销毁通知 token 。 但后来我收到警告:

RLMNotificationToken released without unregistering a notification. You must hold on to the RLMNotificationToken returned from addNotificationBlock and call removeNotification: when you no longer wish to recieve RLMRealm notifications.

我该如何抑制这个警告,因为它毫无意义?

最佳答案

在取消分配通知 token 时记录它的原因是为了防止用户在他们希望接收通知的期间意外忘记持有对其的强引用。

我鼓励您调用 -[RLMNotificationToken stop]当您不想再收到更改通知时。

要抑制此警告,您应该在不再关心接收它们时调用 removeNotification(例如,当您的 ViewController 被关闭时)。

即使取消分配通知 token 具有相同的效果,调用 -stop 将更好地传达那里的意图。

关于ios - 警告 : RLMNotificationToken released without unregistering,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31195215/

相关文章:

iphone - ios writeToFile 更改不保存

objective-c - indexPathForSelectedRow 总是返回 0,0 而不管选择的行

realm - 使用链接属性创建 Realm 记录

ios - Realm 是否支持模型版本?

swift - 如何循环遍历子列表<Object>?

xcode - 无法将 Realm 框架导入 swift 项目

ios - 从文档文件夹中获取所有图像

ios - UITapGestureRecognizer - 忽略顶部对象的点击并将其传递到其下方的对象

ios - 从 TextBox 到 Widget 的文本?

ios - 在 swift 4 中设置和获取数组时发生了奇怪的事情