首页 > 代码库 > iOS 版本信息 包含6,6plus
iOS 版本信息 包含6,6plus
导入#import <sys/sysctl.h>
/**
* iPhone的设备号**/
+ (NSString *)iPhoneVersion
{
NSString *iPhoneVersion = nil;
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = (char*)malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
free(machine);
if ([platform isEqualToString:@"iPhone1,1"]) {
iPhoneVersion = @"iPhone";
}
if ([platform isEqualToString:@"iPhone1,2"]) {
iPhoneVersion = @"iPhone 3G";
}
if ([platform isEqualToString:@"iPhone2,1"]) {
iPhoneVersion = @"iPhone 3GS";
}
if ([platform isEqualToString:@"iPhone3,1"] || [platform isEqualToString:@"iPhone3,2"] || [platform isEqualToString:@"iPhone3,3"]) {
iPhoneVersion = @"iPhone 4";
}
if ([platform isEqualToString:@"iPhone4,1"]) {
iPhoneVersion = @"iPhone 4S";
}
if ([platform isEqualToString:@"iPhone5,1"] || [platform isEqualToString:@"iPhone5,2"]) {
iPhoneVersion = @"iPhone 5";
}
if ([platform isEqualToString:@"iPhone5,3"] || [platform isEqualToString:@"iPhone5,4"]) {
iPhoneVersion = @"iPhone 5c";
}
if ([platform isEqualToString:@"iPhone6,1"] || [platform isEqualToString:@"iPhone6,2"]) {
iPhoneVersion = @"iPhone 5s";
}
if ([platform isEqualToString:@"iPhone7,2"]) {
iPhoneVersion = @"iPhone 6";
}
if ([platform isEqualToString:@"iPhone7,1"]) {
iPhoneVersion = @"iPhone 6Plus";
}
return iPhoneVersion;
}
更多标签对比:http://theiphonewiki.com/wiki/Models
iOS 版本信息 包含6,6plus
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。