I think there is a design issue here. The observed object does not have to care about these observers. You say you want to remove observers from the dealloc method of observed objects. But why is he freed? If it is still observed, there is ownership somewhere, so the facility will not be canceled. Good design means that by the time dealloc is called, there are no more watchers left.
Imagine a view that registers as an observer for a model object. This model object is stored either in the view or in the controller. The model object will not call it dealloc until it is stored somewhere. Only after the release of the last owner should he call dealloc. Therefore, say that all owners are freed, except for the view / viewcontroller, and there is one observer left (view). Now, before the view / viewcontroller releases its ownership of the model object, it must also remove the view as an observer. Therefore, by the time the dealloc method is called, there should be no observer.
source share