32

Is it possible to deprecate an entire protocol? I'm using the GCC compiler that is shipped with iOS SDK 5.0 Beta 7.

DEPRECATED_ATTRIBUTE doesn't seem to work.

For example, the following two statements do not compile.

  • @protocol DEPRECATED_ATTRIBUTE MyProtocol
  • @protocol MyProtocol DEPRECATED_ATTRIBUTE
Chris Frederick
  • 5,482
  • 3
  • 36
  • 44
Hyperbole
  • 3,917
  • 4
  • 35
  • 54

1 Answers1

59

I haven't tried this myself, but I think that the following syntax should work.

__attribute__ ((deprecated))
@protocol MyProtocol
@end

This parallels the syntax for deprecating an entire interface as well as a single method.

__attribute__ ((deprecated))
@interface MyClass
@end

@interface MyClass2
- (void) method __attribute__((deprecated));
@end
Chris Frederick
  • 5,482
  • 3
  • 36
  • 44
  • Huh. Totally didn't think about that. – Hyperbole Sep 13 '11 at 23:21
  • 13
    I realize this is old, but just as a sidenote, as of recent Clang versions you can just use: ```__deprecated``` as shorthand for ```__attribute__ ((deprecated))```. – mszaro Apr 03 '14 at 22:39
  • 6
    `__deprecated` has nothing to do with clang versions. It's provided by the system headers in /usr/include/sys/cdefs.h. You can also use `__deprecated_msg("A note to the developers using it.")` and the compiler print the message along with the deprecation notice. – Jeremy Huddleston Sequoia Aug 16 '15 at 16:51