I have a class and I'm using it as an observer of itself. I need it to notify me when other objects change its properties. When it gets deallocated I don't bother to remove the observer. However I get errors like this one:
An instance 0xf819680 of class **** was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
Now, I don't really get why this would be an issue. My understanding of KVO is that if object A wants to observe object B then A retains B and then
[B addObserver:A]; // shortened just to get the point across
and B does NOT retain A to avoid a cycle. Therefore, if A gets dealloced it must remove itself as an observer of B otherwise B would not have a reference to where A used to be (since it did NOT retain A).
However, this warning seems to imply that if I deallocate B something bad would happen. The only thing I can imagine happening is that the weak reference to A that B has would go away and A would just not get any more notifications. I don't know how "Observation info was leaked." If B goes away, why doesn't the observation info that it was storing go away?