Heath Borders
Heath Borders

Reputation: 32117

How do I mark a UIKit class or method as deprecated?

I'm using a security framework in iOS that doesn't work with UIDocumentInteractionController. I want other developers to get a warning if they try to use this class. I've tried the following, and it doesn't work. Any ideas?

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

Upvotes: 3

Views: 479

Answers (1)

user23743
user23743

Reputation:

#pragma GCC poison interactionControllerWithURL

Note the lack of a colon. Poison is designed to work with C symbols, not Objective-C selectors. However, it will do what you need here.

(The pragma was introduced in GCC but clang supports it too, BTW).

Upvotes: 4

Related Questions