How to abandon a method in Xcode 4

I just looked through the answers here , but didn't help. When I add an obsolete attribute only to a method declaration, than the compiler says Attributes on method implementation and its declaration must match . Does smth need to be added to the method implementation?

Thank!

+6
methods ios deprecated xcode xcode4
Apr 11 2018-12-12T00:
source share
2 answers

Just add the attribute to the ad:

 @interface Blah - (void)method __attribute__((deprecated)); @end 

If your sentences are correct for translation, this should work fine. Perhaps you added the attribute to the definition, and not to the declaration? Otherwise, a demo will help (sample code).

Update

Although the above approach works for typical messages, it seems that clang is confused with IBAction s.

With clang, IBAction attributes are implicitly inserted (for what used to be typedef ).

If the attribute is specified only in the declaration, the output of the preprocessor is as follows:

 // preprocessed declaration - (void)__attribute__((ibaction))setSomething:(id)sender __attribute__((noreturn)); // preprocessed implementation - (void)__attribute__((ibaction))setSomething:(id)sender ... 

So, it seems that the compiler is just confused by this hidden decoration, and you should also add an attribute to the implementation / definition to suppress the warning when the method is an IBAction .

+13
Apr 11 '12 at 7:01
source share

You must specify an obsolete attribute for both the declaration and the method implementation, at least in Xcode 4.3.2 using clang.

0
Apr 11 '12 at 6:45
source share



All Articles