问题描述
我有一个程序需要在 Tiger 和 Leopard 上的行为略有不同.有没有人知道一个系统调用,它可以让我准确地确定我正在运行的 Mac OS X 版本.我找到了许多宏定义来确定构建机器的操作系统,但没有什么能真正确定运行机器的操作系统.
I have a program which needs to behave slightly differently on Tiger than on Leopard. Does anybody know of a system call which will allow me to accurately determine which version of Mac OS X I am running. I have found a number of macro definitions to determine the OS of the build machine, but nothing really good to determine the OS of the running machine.
谢谢,乔
推荐答案
但简而言之,如果您使用的是 carbon,请使用 Gestalt() 调用,如果您使用的是可可,则有一个名为 NSAppKitVersionNumber 的常量,您可以简单地检查它.
But in short, if you're using carbon, use the Gestalt() call, and if you're using cocoa, there is a constant called NSAppKitVersionNumber which you can simply check against.
编辑:对于 Mac OSX 10.8 及更高版本,不再使用格式塔().有关更多详细信息,请参阅此答案:如何在 OS X 或 iOS 中确定运行时的操作系统版本(不使用格式塔)?
Edit: For Mac OSX 10.8 and above, don't use Gestalt() anymore. See this answer for more details: How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?
这篇关于如何以编程方式确定正在运行的 Mac OS X 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!