As Mac OS X evolves, the list of APIs and technologies it encompasses are sometimes changed to meet the needs of developers. As part of this evolution, less efficient interfaces may be deprecated in favor of newer, more efficient ones. Apple makes these changes only when it is deemed absolutely necessary and uses the availability macros (defined in /usr/include/AvailabilityMacros.h) to help you find deprecated interfaces.
Note: Deprecation does not mean the deletion of an interface from a framework or library. It is simply a way to flag interfaces for which better alternatives exists. For example, an older interface may be discouraged in favor of a newer, more efficient interface. You may still use deprecated interfaces in your code; however, Apple recommends you migrate to newer interfaces as soon as possible. Check the header files or documentation of the deprecated interface for information about any recommended replacement interfaces.
Each deprecated interface is tagged with a macro that identifies the version of Mac OS X in which it was marked as deprecated. For example, an interface that was introduced in Mac OS X version 10.0 but deprecated in version 10.3 might have the following macro after its header-file declaration:
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3
If you compiled your project to run on Mac OS X version 10.3 and used an interface tagged with this macro, you would get a warning that the interface is now deprecated. The macro accomplishes this by adding the following attribute to the interface declaration:
__attribute__((deprecated))
When your code references a function that is tagged with this attribute, the compiler generates a warning. The warning includes the name of the deprecated interface and where in your code it was referenced. For example, if the HPurge function were deprecated, you might get an error similar to the following:
'HPurge' is deprecated (declared at /Users/steve/MyProject/main.c:51)
To locate references to deprecated interfaces, you can look for warnings of this type. If your project has a lot of warnings, you can use the search field in Xcode to filter the list based on the “deprecated” keyword.
Last updated: 2006-11-07