【问题标题】:How do I mark a UIKit class or method as deprecated?如何将 UIKit 类或方法标记为已弃用?
【发布时间】:2013-06-10 19:29:59
【问题描述】:

我在 iOS 中使用的安全框架不适用于 UIDocumentInteractionController。我希望其他开发人员在尝试使用此类时收到警告。我尝试了以下方法,但它不起作用。有什么想法吗?

MyApp.pch

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import "UIDocumentInteractionController+JVAdditions.h"
#endif

UIDocumentInteractionController+Additions.h

#import <UIKit/UIKit.h>
@interface UIDocumentInteractionController ()

+ (UIDocumentInteractionController *)interactionControllerWithURL:(NSURL *)url __attribute__((deprecated));

@end

【问题讨论】:

    标签: ios warnings clang deprecated


    【解决方案1】:
    #pragma GCC poison interactionControllerWithURL
    

    注意没有冒号。 Poison 被设计为使用 C 符号,而不是 Objective-C 选择器。但是,它会在这里满足您的需求。

    (在 GCC 中引入了编译指示,但 clang 也支持它,顺便说一句)。

    【讨论】:

    • 太棒了。谢谢你。
    猜你喜欢
    • 2014-08-20
    • 2021-12-27
    • 1970-01-01
    • 2012-02-20
    • 2010-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多