When to use "#if __IPHONE_OS_VERSION_MIN_REQUIRED> x"?
This question describes how to conditionally enable code based on an iOS version. But how does it work?
Suppose I set the iOS Deployment Target to 3.2 in Xcode 4.5.2. In my code, I insert some #ifdef :
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0 // Some iOS 4+ code #endif If I run the code on device 3.2, this code will not be there, but if I run it on device 4.3, it will, right? How does this happen? Or I do not understand what is happening here?
This is a compile time check, so it will create the same behavior in any version of iOS. Since the deployment target is less than 4.0, the code inside the if statement will not work on any device.
If you require the described behavior, you need to perform a runtime check. You can see an example of how to do this in the thread you linked.