I’m writing an Objective-C application using ARC and it’s definitely a great improvement even though I never really minded retain counts. However, there’s one case I couldn’t find in the documentation on first glance.
If, in my init method, I call [self addObserver:self forKeyPath:…] to get notifications of when an ivar declared using an @property directive, do I need to explicitly call removeObserver… in the dealloc method, or does ARC handle key value observer cleanup? Similarly if I add my object to a NSNotificationCenter, does that need to be explicitly removed in dealloc?
You need to call
removeObserver, ARC only automates retain counts.removeObserverdoes not impact the retain count