ytschg
Last Updated: February 25, 2016
·
1.55K
· cherifya
1f00639772b36298e7fdfe8ad8ce64b3

Backward compatible usage of iOS 6 APIs

Need to use iOS 6 specific APIs while maintaining backward compatibility in your app? Use conditional compilation preprocessor flags :

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
    #define IF_IOS6_OR_GREATER(...) \
    if(kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iPhoneOS_6_0) \
    { \
        __VA_ARGS__ \
    }
#else
    #define IF_IOS6_OR_GREATER(...)
#endif

Now you can safely wrap iOS 6 specific code with the IFIOS6OR_GREATER macro like this:

IF_IOS6_OR_GREATER  {
    //do iOS6 specific stuff...
};