How do I target a specific version of Mac OS X?

If I want to target all iOS devices version 4.3 or later, I can use:

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_3 

Also, if I want to target iOS devices in general, I can use:

 #if TARGET_OS_IPHONE 

Is there something similar for Mac OS X?

+6
source share
1 answer

NSAppKitVersionNumber is your friend in OS X. To target, for example. 10.5 and above, you can do this:

 #if NSAppKitVersionNumber >= NSAppKitVersionNumber10_5 // ... #endif 

Edit: We just saw that on OS X there are also __MAC_OS_X_VERSION_MAX_ALLOWED and __MAC_OS_X_VERSION_MIN_REQUIRED , which can work better and are available in Availability.h , which is Cocoa independent.

+3
source

Source: https://habr.com/ru/post/917314/


All Articles