我刚刚看了答案here https://stackoverflow.com/questions/4924285/how-to-deprecate-a-method-in-xcode但没有帮助。当我仅将不推荐使用的属性添加到方法声明时,编译器会说Attributes on method implementation and its declaration must match
。我需要在方法实现中添加一些东西吗?
Thanks!
只需将属性添加到声明中即可:
@interface Blah
- (void)method __attribute__((deprecated));
@end
如果您的包含内容对于翻译是正确的,那么这应该可以正常工作。也许您已将该属性添加到定义,不是宣言?否则,演示(代码示例)会有所帮助。
Update
尽管上述方法适用于典型消息,但 clang 似乎与IBAction
s.
伴随着铿锵声,ibaction
属性是隐式插入的(对于以前的typedef
).
当仅在声明中指定该属性时,预处理器输出如下:
// preprocessed declaration
- (void)__attribute__((ibaction))setSomething:(id)sender __attribute__((noreturn));
// preprocessed implementation
- (void)__attribute__((ibaction))setSomething:(id)sender
...
因此,编译器似乎只是被这种隐藏的修饰所困惑,并且您还必须将该属性添加到实现/定义中,以在该方法是方法时抑制警告IBAction
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)