I've just looked over the answers here but didn't help. When I add a deprecated attribute only to method declaration than the compiler says Attributes on method implementation and its declaration must match
. Do I need to add smth to method implementation?
Thanks!
Just add the attribute to the declaration:
@interface Blah
- (void)method __attribute__((deprecated));
@end
Provided your includes are correct for the translation, this should work fine. Perhaps you have added the attribute to the definition, not the declaration? Otherwise, a demonstration (code sample) would help.
Update
Although the above approach works for typical messages, it appears clang gets confused with IBAction
s.
With clang, ibaction
attributes are implicitly inserted (for what was formerly a typedef
).
When the attribute is specified in the declaration only, the preprocessor output is as follows:
// preprocessed declaration
- (void)__attribute__((ibaction))setSomething:(id)sender __attribute__((noreturn));
// preprocessed implementation
- (void)__attribute__((ibaction))setSomething:(id)sender
...
So, it appears the compiler is just confused by this hidden decoration, and you must also add the attribute to the implementation/definition to suppress the warning when the method is an IBAction
.
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