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?
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.
"Have you tried turning it off and on again?"
This is a silly answer, but cleaning the target and restarting Xcode has solved this very irritating behavior for me
- Menu > Product > Clean
- Menu > Product > (press the alt key) Clean Project Folder
- restart Xcode
After that, I got more ARC related warnings, so clearly, Xcode wasn't finished converting to ARC. Now the warning is gone and everything works just fine.
来源:https://stackoverflow.com/questions/12156379/missing-super-dealloc-warning-in-an-arc-project
