I\'ve got an iPhone app that\'s mainly targetting 3.0, but which takes advantage of newer APIs when they\'re available. Code goes something like this:
if (UI
Here is what I had to do when checking for an external framework constant.
const CLLocationAccuracy * ptr = &kCLLocationAccuracyBestForNavigation;
BOOL frameworkSupports = (ptr != NULL);
if (frameworkSupports) {
return kCLLocationAccuracyBestForNavigation;
} else {
return kCLLocationAccuracyBest;
}
It would not work without the ptr variable.
Aaand I figured it out. For symbols that are not functions (extern const int foobar
, for instance), you have to compare against the address of the symbol, not the symbol itself, so:
if (&UIApplicationWillEnterForegroundNotification != NULL)
etc;
Which in retrospect is kind of obvious, but I still fault the entire universe around me for not ever mentioning the distinction.