NSString * getDeviceType() {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *deviceType = [NSString stringWithCString:machine
encoding:NSUTF8StringEncoding];
free(machine);
if ([deviceType isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";
if ([deviceType isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([deviceType isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([deviceType isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([deviceType isEqualToString:@"iPhone3,2"]) return @"iPhone 4";
if ([deviceType isEqualToString:@"iPhone3,3"]) return @"iPhone 4";
if ([deviceType isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
if ([deviceType isEqualToString:@"iPhone5,1"]) return @"iPhone 5";
if ([deviceType isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)";
if ([deviceType isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)";
if ([deviceType isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)";
if ([deviceType isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)";
if ([deviceType isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)";
if ([deviceType isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus";
if ([deviceType isEqualToString:@"iPhone7,2"]) return @"iPhone 6";
if ([deviceType isEqualToString:@"iPhone8,1"]) return @"iPhone 6s";
if ([deviceType isEqualToString:@"iPhone8,2"]) return @"iPhone 6s Plus";
if ([deviceType isEqualToString:@"iPhone8,4"]) return @"iPhone SE";
if ([deviceType isEqualToString:@"iPhone9,1"]) return @"iPhone 7";
if ([deviceType isEqualToString:@"iPhone9,3"]) return @"iPhone 7";
if ([deviceType isEqualToString:@"iPhone9,2"]) return @"iPhone 7 Plus";
if ([deviceType isEqualToString:@"iPhone9,4"]) return @"iPhone 7 Plus";
if ([deviceType isEqualToString:@"iPhone10,1"]) return @"iPhone 8";
if ([deviceType isEqualToString:@"iPhone10,4"]) return @"iPhone 8";
if ([deviceType isEqualToString:@"iPhone10,2"]) return @"iPhone 8 Plus";
if ([deviceType isEqualToString:@"iPhone10,5"]) return @"iPhone 8 Plus";
if ([deviceType isEqualToString:@"iPhone10,3"]) return @"iPhone X";
if ([deviceType isEqualToString:@"iPhone10,6"]) return @"iPhone X";
if ([deviceType isEqualToString:@"iPhone11,8"]) return @"iPhone XR";
if ([deviceType isEqualToString:@"iPhone11,2"]) return @"iPhone XS";
if ([deviceType isEqualToString:@"iPhone11,4"]) return @"iPhone XS Max";
if ([deviceType isEqualToString:@"iPhone11,6"]) return @"iPhone XS Max";
if ([deviceType isEqualToString:@"iPod1,1"]) return @"iPod Touch (1 Gen)";
if ([deviceType isEqualToString:@"iPod2,1"]) return @"iPod Touch (2 Gen)";
if ([deviceType isEqualToString:@"iPod3,1"]) return @"iPod Touch (3 Gen)";
if ([deviceType isEqualToString:@"iPod4,1"]) return @"iPod Touch (4 Gen)";
if ([deviceType isEqualToString:@"iPod5,1"]) return @"iPod Touch (5 Gen)";
if ([deviceType isEqualToString:@"iPad1,1"]) return @"iPad";
if ([deviceType isEqualToString:@"iPad1,2"]) return @"iPad 3G";
if ([deviceType isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)";
if ([deviceType isEqualToString:@"iPad2,2"]) return @"iPad 2";
if ([deviceType isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)";
if ([deviceType isEqualToString:@"iPad2,4"]) return @"iPad 2";
if ([deviceType isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)";
if ([deviceType isEqualToString:@"iPad2,6"]) return @"iPad Mini";
if ([deviceType isEqualToString:@"iPad2,7"]) return @"iPad Mini (GSM+CDMA)";
if ([deviceType isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)";
if ([deviceType isEqualToString:@"iPad3,2"]) return @"iPad 3 (GSM+CDMA)";
if ([deviceType isEqualToString:@"iPad3,3"]) return @"iPad 3";
if ([deviceType isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)";
if ([deviceType isEqualToString:@"iPad3,5"]) return @"iPad 4";
if ([deviceType isEqualToString:@"iPad3,6"]) return @"iPad 4 (GSM+CDMA)";
if ([deviceType isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)";
if ([deviceType isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)";
if ([deviceType isEqualToString:@"iPad4,4"]) return @"iPad Mini 2 (WiFi)";
if ([deviceType isEqualToString:@"iPad4,5"]) return @"iPad Mini 2 (Cellular)";
if ([deviceType isEqualToString:@"iPad4,6"]) return @"iPad Mini 2";
if ([deviceType isEqualToString:@"iPad4,7"]) return @"iPad Mini 3";
if ([deviceType isEqualToString:@"iPad4,8"]) return @"iPad Mini 3";
if ([deviceType isEqualToString:@"iPad4,9"]) return @"iPad Mini 3";
if ([deviceType isEqualToString:@"iPad5,3"]) return @"iPad Air 2";
if ([deviceType isEqualToString:@"iPad5,4"]) return @"iPad Air 2";
if ([deviceType isEqualToString:@"iPad6,3"]) return @"iPad Pro 9.7";
if ([deviceType isEqualToString:@"iPad6,4"]) return @"iPad Pro 9.7";
if ([deviceType isEqualToString:@"iPad6,7"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad6,8"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad7,1"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad7,2"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad8,5"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad8,6"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad8,7"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad8,8"]) return @"iPad Pro 12.9";
if ([deviceType isEqualToString:@"iPad7,3"]) return @"iPad Pro 10.5";
if ([deviceType isEqualToString:@"iPad7,4"]) return @"iPad Pro 10.5";
if ([deviceType isEqualToString:@"iPad8,1"]) return @"iPad Pro 11.0";
if ([deviceType isEqualToString:@"iPad8,2"]) return @"iPad Pro 11.0";
if ([deviceType isEqualToString:@"iPad8,3"]) return @"iPad Pro 11.0";
if ([deviceType isEqualToString:@"iPad8,4"]) return @"iPad Pro 11.0";
if ([deviceType isEqualToString:@"i386"]) return @"Simulator";
if ([deviceType isEqualToString:@"x86_64"]) return @"Simulator";
return @"unknown";
}
iOS设备类型对应表
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 小学语文修改病句的方法 修改病句是小学语文考试中常见的题型,在修改病句之前,我们应该清晰的了解有哪些病句现象,下面...