您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页声明类或者方法被DEPRECATED

声明类或者方法被DEPRECATED

来源:二三四教育网

可以使用系统的NS_DEPRECATED开头的宏,这个宏需要指定系统版本,我们又不是系统的开发者,不需要指定系统版本。

使用 attribute

  1. 标记类 deprecated

     __attribute__((deprecated("Class A is deprecated , use Class B instead")))
    
     @interface ClassA : NSObject
    
  2. 标记方法 deprecated

     - (void)functionA __attribute__((deprecated("functionA is deprecated, use functionAWithParams: instead")));
    

可以同时加上注释

/**
 *  Class A is deprecated , use Class B instead
 */
 __attribute__((deprecated("Class A is deprecated , use Class B instead")))

 @interface ClassA : NSObject

重构过程中,虽然说过那些内容即将被废弃,但是还是有人会去使用,所以加上声明会好些。

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务