我的目标是收集 OS 版本,MAC 10.10 的发布细节。
我找到了一种方法来收集 MAC 10.10 以及上一个版本的详细信息。来自链接的版本
如何在 OS X 或 iOS(不使用格式塔)中确定运行时的操作系统版本?
当我编译它在“objc_msgSend_stret”时抛出错误,当我搜索 /usr/include/objc 文件夹本身时我的 MAC 中不存在。我只能看到 gcc 存在,我所有的代码都是用它构建的。
有没有最好的方法来复制输出
[[NSProcessInfo processInfo], @selector(operatingSystemVersion)] 到结构为“MyOperatingSystemVersion”?
typedef struct {
NSInteger majorVersion;
NSInteger minorVersion;
NSInteger patchVersion;
} MyOperatingSystemVersion;
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
MyOperatingSystemVersion version = ((MyOperatingSystemVersion(*)(id, SEL))objc_msgSend_stret)([NSProcessInfo processInfo], @selector(operatingSystemVersion));
// do whatever you want with the version struct here
}
else {
UInt32 systemVersion = 0;
OSStatus err = Gestalt(gestaltSystemVersion, (SInt32 *) &systemVersion);
// do whatever you want with the systemVersion as before
}