不确定为什么其他人说这是不可能的,因为它使用sysctl
函数。
#import <sys/sysctl.h>
- (NSString *)osVersionBuild {
int mib[2] = {CTL_KERN, KERN_OSVERSION};
u_int namelen = sizeof(mib)/sizeof(mib[0]);
size_t bufferSize = 0;
NSString *osBuildVersion = nil;
// Get the size for the buffer
sysctl(mib, namelen, NULL, &bufferSize, NULL, 0);
u_char buildBuffer[bufferSize];
int result = sysctl(mib, namelen, buildBuffer, &bufferSize, NULL, 0);
if (result >= 0) {
osBuildVersion = [[[NSString alloc] initWithBytes:buildBuffer length:bufferSize encoding:NSUTF8StringEncoding] autorelease];
}
return osBuildVersion;
}
为了记录,该字符串是内部版本号。 – Chuck 2011-02-03 22:19:04