Where developers come to connect, share, build and be inspired.

1

Backward compatible usage of iOS 6 APIs

720 views

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...
};

Comments

Add a comment