tags:

views:

17

answers:

2

Is there any way to get XCode to toss a warning out if a method may not be available on an older version? For example, my app might have a deployment target of 3.0, but a supported SDK of up to 4.0. That means that I might use methods that can be used on 4.0, but definitely aren't available when running on a 3.0 device.

A: 

Get info on your project (or target) and modify the "Preprocessor Macros" setting to add

__IPHONE_OS_VERSION_MAX_ALLOWED=30000

The specific number depends on the SDK, and can be found in the Availability.h header.

Kevin Ballard
A: 

This is one way. You can also use a class objects method respondsToSelector:(@selector) to ask whether or not a particular object responds to a particular command. This is useful when you want to support features only available in 4.0, but also want the program to run in 3.0 without that feature. This also goes for hardware that may or may not be available. For example, you might need to check if a device has a gyroscope before you starting asking it about the state of its gyro (ie iPhone 4 vs 3GS/3G).

fogelbaby