Jamie Chapman Jamie Chapman - 1 year ago 184
Objective-C Question

How do I flag a method as deprecated in Objective-C 2.0?

I'm part of a team developing a fairly large iPad app and there are many different classes we've created as a result. The trouble is some of the methods are now pretty much obsolete and I don't want simply remove them yet as I know some parts of the overall system use the methods... but there are better (newer) variants available which should be used instead (some of the old ones actually call the new ones, but the overall class interface is getting messy).

Is there a way in which I can mark certain methods as depreciated (like

in Java and
in .NET).

I see that Apple use Availability.h and have tags such as


... is this the only way to do it (+ is it App Store safe to do this?) or are there alternatives which will flag a warning in Xcode?

Answer Source

Deprecation Syntax

Syntax is provided to mark methods as deprecated:

@interface SomeClass
-method __attribute__((deprecated));


#include <AvailabilityMacros.h>
@interface SomeClass
-method DEPRECATED_ATTRIBUTE;  // or some other deployment-target-specific macro
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download