"Missing [super dealloc]" warning in an ARC project

automatic-ref-counting, ios, xcode

Solution

Put the following lines into your dealloc method to make sure it is compiled with ARC enabled:

#if ! __has_feature(objc_arc)
#error "ARC is off"
#endif

If you get the compiler error when building, you're sure that ARC is off and have to search for the reason. It's probably in per-file build settings in your target.

Problem

I've refactored a project to ARC. It looks fine, but there is an object which uses the notification center. I removed the observer in a custom dealloc method. That worked fine in the non ARC project. It also works in ARC, but I get a crazy warning: "Method possibly missing a [super dealloc] call." In an ARC project it is automatically done for me, when the method ends. Even better: I must not call it in ARC projects! This must be an XCode bug, right? Here's my code: ``` - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; // [super dealloc]; will be called automatically } ``` I always want to write code that doesn't throw warnings. Is there a way around that yellow exclamation mark?

Original source