What's the device code (platform string) for i

2019-03-08 20:12发布

For example, is it "iPhone5,1" or "iPhone5,2" for iPhone 5? And what's the difference?

If anyone has the iPhone 5, please help by running the following code and showing your result. Thank you.

Related Link: https://stackoverflow.com/a/3950748/482899

9条回答
手持菜刀,她持情操
2楼-- · 2019-03-08 20:19

You can find a list of all iOS device identifiers here (including iPhone 5 models and iPad mini): http://theiphonewiki.com/wiki/index.php?title=Models

The identifiers of the latest models are:

iPhone 5: iPhone5,1 and iPhone5,2

iPhone 5C: iPhone5,3 and iPhone5,4

iPhone 5S: iPhone6,1 and iPhone6,2

iPhone 6: iPhone7,2

iPhone 6 Plus: iPhone7,1

iPhone 6S: iPhone8,1

iPhone 6S Plus: iPhone8,2

iPhone SE: iPhone8,4

iPhone 7: iPhone9,1 and iPhone9,3

iPhone 7 Plus: iPhone9,2 and iPhone9,4

iPhone 8: iPhone10,1 and iPhone10,4

iPhone 8 Plus: iPhone10,2 and iPhone10,5

iPhone X: iPhone10,3 and iPhone10,6

EDIT: I also made an updated version of the popular iOS Support Matrix including all models up to iPhone X.

查看更多
爷的心禁止访问
3楼-- · 2019-03-08 20:22
if ([platform isEqualToString:@"iPhone1,1"])    return @"iPhone 2G";
if ([platform isEqualToString:@"iPhone1,2"])    return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"])    return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"])    return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,2"])    return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"])    return @"iPhone 4 (CDMA)";
if ([platform isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"])    return @"iPhone 5";
if ([platform isEqualToString:@"iPhone5,2"])    return @"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"])    return @"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,4"])    return @"iPhone 5c (UK+Europe+Asia+China)";
if ([platform isEqualToString:@"iPhone6,1"])    return @"iPhone 5s (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,2"])    return @"iPhone 5s (UK+Europe+Asia+China)";
if ([platform isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
if ([platform isEqualToString:@"iPhone7,2"])    return @"iPhone 6";

if ([platform isEqualToString:@"iPod1,1"])      return @"iPod Touch (1 Gen)";
if ([platform isEqualToString:@"iPod2,1"])      return @"iPod Touch (2 Gen)";
if ([platform isEqualToString:@"iPod3,1"])      return @"iPod Touch (3 Gen)";
if ([platform isEqualToString:@"iPod4,1"])      return @"iPod Touch (4 Gen)";
if ([platform isEqualToString:@"iPod5,1"])      return @"iPod Touch (5 Gen)";
if ([platform isEqualToString:@"iPod7,1"])      return @"iPod Touch (6 Gen)";

if ([platform isEqualToString:@"iPad1,1"])      return @"iPad";
if ([platform isEqualToString:@"iPad1,2"])      return @"iPad 3G";
if ([platform isEqualToString:@"iPad2,1"])      return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"])      return @"iPad 2";
if ([platform isEqualToString:@"iPad2,3"])      return @"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"])      return @"iPad 2";
if ([platform isEqualToString:@"iPad2,5"])      return @"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"])      return @"iPad Mini";
if ([platform isEqualToString:@"iPad2,7"])      return @"iPad Mini (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,1"])      return @"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"])      return @"iPad 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,3"])      return @"iPad 3";
if ([platform isEqualToString:@"iPad3,4"])      return @"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"])      return @"iPad 4";
if ([platform isEqualToString:@"iPad3,6"])      return @"iPad 4 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,1"])      return @"iPad Air (WiFi)";
if ([platform isEqualToString:@"iPad4,2"])      return @"iPad Air (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,4"])      return @"iPad Mini 2 (WiFi)";
if ([platform isEqualToString:@"iPad4,5"])      return @"iPad Mini 2 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,6"])      return @"iPad Mini 2 (China)";
if ([platform isEqualToString:@"iPad4,7"])      return @"iPad Mini 3 (WiFi)";
if ([platform isEqualToString:@"iPad4,8"])      return @"iPad Mini 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,9"])      return @"iPad Mini 3 (China)";
if ([platform isEqualToString:@"iPad5,3"])      return @"iPad Air 2 (WiFi)";
if ([platform isEqualToString:@"iPad5,4"])      return @"iPad Air 2";

if ([platform isEqualToString:@"i386"])         return @"Simulator";
if ([platform isEqualToString:@"x86_64"])       return @"Simulator";

return platform;  
查看更多
祖国的老花朵
4楼-- · 2019-03-08 20:28

This method covers all devices in market:

- (NSString *) platform{
int mib[2];
size_t len;
char *machine;

mib[0] = CTL_HW;
mib[1] = HW_MACHINE;
sysctl(mib, 2, NULL, &len, NULL, 0);
machine = malloc(len);
sysctl(mib, 2, machine, &len, NULL, 0);

NSString *platform = [NSString stringWithCString:machine encoding:NSASCIIStringEncoding];
free(machine);
return platform; }

- (NSString *) platformString{
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"])    return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"])    return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"])    return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"])    return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"])    return @"Verizon iPhone 4";
if ([platform isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"])    return @"iPhone 5 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"])    return @"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"])    return @"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,4"])    return @"iPhone 5c (UK+Europe+Asia+China)";
if ([platform isEqualToString:@"iPhone6,1"])    return @"iPhone 5s (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,2"])    return @"iPhone 5s (UK+Europe+Asia+China)";
if ([platform isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
if ([platform isEqualToString:@"iPhone7,2"])    return @"iPhone 6";
if ([platform isEqualToString:@"iPhone8,1"])    return @"iPhone 6s";
if ([platform isEqualToString:@"iPhone8,2"])    return @"iPhone 6s Plus";
if ([platform isEqualToString:@"iPhone8,4"])    return @"iPhone SE";
if ([platform isEqualToString:@"iPhone9,1"])    return @"iPhone 7";
if ([platform isEqualToString:@"iPhone9,2"])    return @"iPhone 7 Plus";
if ([platform isEqualToString:@"iPhone9,3"])    return @"iPhone 7";
if ([platform isEqualToString:@"iPhone9,4"])    return @"iPhone 7 Plus";


if ([platform isEqualToString:@"iPod1,1"])      return @"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"])      return @"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"])      return @"iPod Touch 3G";
if ([platform isEqualToString:@"iPod4,1"])      return @"iPod Touch 4G";
if ([platform isEqualToString:@"iPod5,1"])      return @"iPod Touch 5G";

if ([platform isEqualToString:@"iPad1,1"])      return @"iPad";
if ([platform isEqualToString:@"iPad1,2"])      return @"iPad 3G";
if ([platform isEqualToString:@"iPad2,1"])      return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"])      return @"iPad 2";
if ([platform isEqualToString:@"iPad2,3"])      return @"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"])      return @"iPad 2";
if ([platform isEqualToString:@"iPad2,5"])      return @"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"])      return @"iPad Mini";
if ([platform isEqualToString:@"iPad2,7"])      return @"iPad Mini (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,1"])      return @"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"])      return @"iPad 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,3"])      return @"iPad 3";
if ([platform isEqualToString:@"iPad3,4"])      return @"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"])      return @"iPad 4";
if ([platform isEqualToString:@"iPad3,6"])      return @"iPad 4 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,1"])      return @"iPad Air (WiFi)";
if ([platform isEqualToString:@"iPad4,2"])      return @"iPad Air (Cellular)";
if ([platform isEqualToString:@"iPad4,4"])      return @"iPad Mini 2 (WiFi)";
if ([platform isEqualToString:@"iPad4,5"])      return @"iPad Mini 2 (Cellular)";
if ([platform isEqualToString:@"iPad4,6"])      return @"iPad Mini 2";
if ([platform isEqualToString:@"iPad4,7"])      return @"iPad Mini 3";
if ([platform isEqualToString:@"iPad4,8"])      return @"iPad Mini 3";
if ([platform isEqualToString:@"iPad4,9"])      return @"iPad Mini 3";
if ([platform isEqualToString:@"iPad5,3"])      return @"iPad Air 2";
if ([platform isEqualToString:@"iPad5,4"])      return @"iPad Air 2";


if ([platform isEqualToString:@"i386"])         return @"Simulator";
if ([platform isEqualToString:@"x86_64"])       return @"Simulator";
return platform; }
查看更多
\"骚年 ilove
5楼-- · 2019-03-08 20:31

Yup, "iPhone5,1" is the GSM iPhone 5, "iPhone5,2" is the CDMA iPhone 5, "iPhone5,3" is the GSM iPhone 5C, "iPhone5,4" is the CDMA iPhone 5C, "iPhone6,1" is the GSM iPhone 5S, and "iPhone6,2" is the CDMA iPhone 5S. Does that answer your question?

查看更多
叛逆
6楼-- · 2019-03-08 20:33

It looks like either iPhone5,1 or iPhone5,2 depending on the model of iPhone 5.

From @marcoarment, who is a well known iOS Developer:

iPhone5,1: model A1428, AT&T/Canada

iPhone5,2: model A1429, all others

A1429 may have two modes, but I don’t see any iPhone5,3 records.

Source: https://twitter.com/marcoarment/status/249249183029161984

查看更多
甜甜的少女心
7楼-- · 2019-03-08 20:36

[Update] platform name of iphone8 is iPhone10,1

[Update] platform name of iphoneX is iPhone10,3

查看更多
登录 后发表回答