将方法标记为已弃用

Gal*_*rom 5 api xcode ios

我的 API 发生了变化,我想将一种方法标记为已弃用。我在它的签名上加上了以下内容: attribute ((deprecated("Don't use this method"))); 但是,我不知道我需要如何在方法体本身中表现。

在 Apple 编码上找不到任何东西开始引导我。该方法返回 BOOL。我应该只返回false吗?

Mid*_* MP 5

弃用意味着该方法仍然有效,但可以在未来版本中删除,新方法是最受青睐的。

您可以向使用已弃用方法的用户提供一些附加信息:

/**
 * @deprecated This method is deprecated starting in version x.x
 * @note Please use @code newMethod:withNewParameter: @endcode instead.
 */
-(void)depFunction:(id)x __attribute__((deprecated));
Run Code Online (Sandbox Code Playgroud)

当他使用类似:

[yourClassObj depFunction:@"argument"];
Run Code Online (Sandbox Code Playgroud)

快速帮助面板将显示如下信息:

已弃用

您可能还想更改attribute((deprecated("Don't use this method")));DEPRECATED_MSG_ATTRIBUTE("Don't use this method, use the other one instead.");