如何在Objective-C 2.0中将方法标记为已弃用? [英] How do I flag a method as deprecated in Objective-C 2.0?

查看:305
本文介绍了如何在Objective-C 2.0中将方法标记为已弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是开发相当大的iPad应用程序的团队的一员,因此我们创建了许多不同的类。麻烦的是一些方法现在已经过时了,我不想简单地删除它们,因为我知道整个系统的某些部分使用方法......但是有更好的(更新的)变体可以使用相反(一些旧的实际上称为新的,但整体类接口变得混乱)。

I'm part of a team developing a fairly large iPad app and there are many different classes we've created as a result. The trouble is some of the methods are now pretty much obsolete and I don't want simply remove them yet as I know some parts of the overall system use the methods... but there are better (newer) variants available which should be used instead (some of the old ones actually call the new ones, but the overall class interface is getting messy).

有没有办法可以将某些方法标记为折旧(如Java中的 @deprecated 和.NET中的 [已废弃] )。

Is there a way in which I can mark certain methods as depreciated (like @deprecated in Java and [Obsolete] in .NET).

我看到Apple使用Availability.h并且有标签,例如

I see that Apple use Availability.h and have tags such as

__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA,__MAC_NA,__IPHONE_2_0,__IPHONE_3_0);

...这是唯一的方法(+ App Store是否可以安全地执行此操作?)或者是否有替代品会在Xcode中标记警告?

... is this the only way to do it (+ is it App Store safe to do this?) or are there alternatives which will flag a warning in Xcode?

推荐答案

弃用语法



提供语法将方法标记为已弃用:

Deprecation Syntax

Syntax is provided to mark methods as deprecated:

@interface SomeClass
-method __attribute__((deprecated));
@end

或:

#include <AvailabilityMacros.h>
@interface SomeClass
-method DEPRECATED_ATTRIBUTE;  // or some other deployment-target-specific macro
@end

这篇关于如何在Objective-C 2.0中将方法标记为已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆