我一直在与漂亮的 PLCrashReport 一起工作框架将来 self 用户的 iOS 设备的崩溃报告发送到我的服务器。
但是,为了表示崩溃报告,symbolicatecrash 实用程序要求我提供 iPhone 操作系统版本号以及 ipsw 的字母数字版本,格式为:
OS Version: iPhone OS 4.0.1 (8A293)
我知道我可以通过 [[UIDevice currentDevice] systemVersion]
获取 iOS 的数字版本,但如何获取另一个?
我找不到办法,我到处搜索我能想到的地方。
最佳答案
不知道为什么其他人说这是不可能的,因为它使用了 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;
}
关于ios - 如何以编程方式获取 iOS 的字母数字版本字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4857195/