KVO - How to get a list of an objects registered observers

Lee Probert picture Lee Probert · May 21, 2012 · Viewed 6.9k times · Source

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.

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

Answer

hp iOS Coder picture hp iOS Coder · May 21, 2012

I dont know, how can you remove observers registered on the same objects.

But i think below method will help you to move little ahead to find your solution.

observationInfo

Returns a pointer that identifies information about all of the observers that are registered with the receiver.

- (void *)observationInfo

The default implementation of this method retrieves the information from a global dictionary keyed by the receiver’s pointers.