我有一个程序需要在Tiger上的行为略有不同于Leopard.有没有人知道系统调用,这将允许我准确地确定正在运行的Mac OS XI版本.我已经找到了许多宏定义来确定构建机器的操作系统,但是没有什么能够确定正在运行的机器的操作系统.
谢谢,乔
我想获得OS X系统版本,例如:10.5.4,10.4.8等.我想在我的应用程序中获取它,我该怎么做?谢谢!
如何从Cocoa Objective-C应用程序中找到Mac OS X的版本号(例如"10.6.7")?
我在一些项目中看到过类似的东西:
#if .....
code...
#endif
Run Code Online (Sandbox Code Playgroud)
但我现在找不到它......
比方说,如果应用程序在10.8运行,应用程序会执行1项操作,如果不是应用程序执行其他操作.什么代码来检查它是否在10.8上运行?
谢谢.
我怎样才能在objective-c中获得OSX版本?我想避免使用shell命令.例如"10.5"或"10.4"
I'm building an application that needs to check what version of OS X is installed on a Mac. It is built against 10.9 Mavericks, but all of the Swift APIs are pretty much 10.10 only.
I'm trying to use the following, however it does not compile against the 10.9 SDK since it does not have these APIs, I know how to use if #available(OSX 10.10, *) to conditionally compile as per the different versions, however because NSProcessInfo is a 10.10+ …
我目前正在使用Mono在C#中编写Mac OSX应用程序.我想要做的是确定程序运行的OSX的版本.
我找到了NSAppKitVersionNumber适合我需要的常数.
但是,我不知道如何访问它...
我相信这是可能的,因此您的任何帮助都将受到高度赞赏!
如果您的代码需要仅在macOS 10.12或更高版本中可用的功能,但又希望代码也可以部署到较早的系统版本,则可以@available在Objective-C中使用:
if (@available(macOS 10.12, *)) {
// Code that requires 10.12 APIs
} else {
// Code that doesn't require 10.12 APIs
}
Run Code Online (Sandbox Code Playgroud)
您可以在Swift中使用#available以下命令执行相同的操作:
if #available(OSX 10.12, *) {
// Code that requires 10.12 APIs
} else {
// Code that doesn't require 10.12 APIs
}
Run Code Online (Sandbox Code Playgroud)
但是,如果编写C或C ++代码,可以使用什么呢?
macos ×7
cocoa ×6
objective-c ×5
swift ×2
c ×1
c# ×1
macos-carbon ×1
mono ×1
monomac ×1
xcode ×1