如何将UIKit类或方法标记为已弃用?

时间:2013-06-10 19:29:59

标签: ios warnings clang deprecated

我在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

1 个答案:

答案 0 :(得分:4)

#pragma GCC poison interactionControllerWithURL

注意缺少冒号。 Poison旨在使用C符号,而不是Objective-C选择器。但是,它会在这里做你需要的。

(该pragma是在GCC中引入的,但clang也支持它,BTW)。