如何获得OS X系统版本? [英] How to get the OS X system version?

查看:88
本文介绍了如何获得OS X系统版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得OS X系统版本,例如:10.5.4,10.4.8等。我想在我的应用程序中获取它,我该怎么做?感谢!

I want to get the OS X system version, such as: 10.5.4, 10.4.8, etc. I want to get it in my app, how do I do this? Thanks!

推荐答案

您可以在/System/Library/CoreServices/SystemVersion.plist中读取属性列表, 键,这是OS X安装程序应用程序的作用。下面是一个例子:

You can read the property list at "/System/Library/CoreServices/SystemVersion.plist and extract the "ProductVersion" key, this is how the OS X installer application does it. Here's an example:

NSString *versionString;
NSDictionary * sv = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
versionString = [sv objectForKey:@"ProductVersion"];

或者,命令 swvers -productVersion 也会这样做。

Alternatively, the command swvers -productVersion will do the same.

这篇关于如何获得OS X系统版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆