KVO - 如何获取已注册观察者的对象列表 [英] KVO - How to get a list of an objects registered observers

查看:117
本文介绍了KVO - 如何获取已注册观察者的对象列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在动态地在一堆tableview控制器上注册一个观察者,所以如果他们在同一个对象上注册,我需要删除以前的观察者。为此,我需要检查对象上是否存在观察者。

I am registering an observer on a bunch of tableview controllers dynamically so I need to remove previous observers if they were registered on the same object. To do this I need to check if the observer exists on the object.

这可能吗?我知道使用NSNotification你可以使用NSNotification中心单例,但这对KVO来说是一样的吗?

Is this possible? I know with NSNotification you can use the NSNotification center singleton but is this the same for KVO?

推荐答案

不,我没有简单的方法。 KVO和NSNotification在这方面有所不同。
如果你需要这个功能,为什么不用NSNotification而不是KVO来实现你的解决方案呢?

No, there is no simple way that I'm aware of. KVO and NSNotification differs in that matter. Why don't you implement your solution with NSNotification instead of KVO if you need that functionality?

这篇关于KVO - 如何获取已注册观察者的对象列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆