首页 文章

Cocoa:在运行时获取Darwin版本

提问于
浏览
0

如何在运行时获取darwin版本?我知道我可以使用 [[NSProcessInfo processInfo] operatingSystemVersion] 获取macOS或iOS版本,但我想要Darwin版本 .

在互联网上有are tables将macOS和iOS版本链接到达尔文版本,但我希望实现这种面向未来的版本 .

1 回答

  • 1

    使用 uname() POSIX / BSD库函数 . 您声明一个 struct utsname 类型的变量并传入其地址 . struct的 release 字段将包含带有Darwin版本号的C字符串,例如"16.3.0" . 如果您希望将各个组件作为整数,则必须自己解析它 .

相关问题