As my iPhone app can run on both OS 3 and 4, I need a way to safely test for iOS 4 SDK features.
I like to avoid checking the [UIDevice ... systemVersion] string (I wonder why Apple failed to provide a numeric value here for easy testing, as it's available on OS X).
Anyway. The usual clean way to test for SDK features is to check if a class reponds to a selector, like this:
if ([UIApplication instancesRespondToSelector:...
And for C methods, one simply checks if the function pointer is NULL:
if (newFunction != NULL) ...
But my problem is that I need to check if a global variable exists. E.g. this one:
extern NSString *const UIApplicationDidEnterBackgroundNotification __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);
Any idea how one can test their existence at runtime?