简体   繁体   English

如何定位特定的Mac OS X版本?

[英]How do I target a specific Mac OS X version?

If I want to target all iOS devices version 4.3 or later, I can use: 如果我想定位所有iOS设备版本4.3或更高版本,我可以使用:

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_3

Also, if I want to target iOS devices in general, I can use: 另外,如果我想一般针对iOS设备,我可以使用:

#if TARGET_OS_IPHONE

Is there something similar for Mac OS X? Mac OS X有类似的东西吗?

NSAppKitVersionNumber is your friend on OS X. To target eg. NSAppKitVersionNumber是您在OS X上的朋友。例如,目标。 10.5 and upwards, you can do this: 10.5及以上,你可以这样做:

#if NSAppKitVersionNumber >= NSAppKitVersionNumber10_5

// ...

#endif

Edit: Just seen that there are also __MAC_OS_X_VERSION_MAX_ALLOWED and __MAC_OS_X_VERSION_MIN_REQUIRED on OS X, which might work better and which are available in the Availability.h which is not Cocoa dependent. 编辑:刚刚看到OS X上还有__MAC_OS_X_VERSION_MAX_ALLOWED__MAC_OS_X_VERSION_MIN_REQUIRED ,这可能效果更好,而且可以在__MAC_OS_X_VERSION_MIN_REQUIRED不依赖的Availability.h中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM