gpt4 book ai didi

ios - 警告 : RLMNotificationToken released without unregistering

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:59:18 26 4
gpt4 key购买 nike

我在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com