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.
I did resolved this warning by following steps:
<yourapp>.xcodeproj
) in which the file(<classname>.m
) class shows above warning-fobjc-arc
This is looks like below
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With