最新ios设备标签与设备型号的对应关系

1164次浏览

1.这种是在较高层次获取设备类型,返回的是 iPhone , iPod , iPad 。适合要求不高的。

1
NSString *deviceType = [[UIDevice currentDevice] model];

2.这是Linux中获取设备类型的方法,主要是C语言的方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <sys/types.h>
#include <sys/sysctl.h>
 
- (NSString *)getDeviceVersionInfo
{
    size_t size;
    // get the length of machine name
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    // get machine name
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithFormat:@"%s", machine];
    free(machine);
 
    return platform;
}
1
2
3
4
5
6
7
8
9
10
#include <sys/utsname.h>
 
- (NSString *)getDeviceVersionInfo
{
    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *platform = [NSString stringWithFormat:@"%s", systemInfo.machine];
 
    return platform;
}

  
通过,如上方式即可获取到设备的型号信息,具体对应关系如下,

iPhone

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	iPhone8,1		iPhone6s
	iPhone8,2		iPhone6s-plus
	iPhone8,4		iPhone5se
	iPhone7,1		iPhone6-plus
	iPhone7,2		iPhone6
	iPhone6,1		iPhone5s
	iPhone6,2		iPhone5s
	iPhone5,1		iPhone5(移动,联通)
	iPhone5,2		iPhone5(移动,电信,联通)
	iPhone5,3		iPhone5c
	iPhone5,4		iPhone5c
	iPhone4,1		iPhone4S
	iPhone3,1		iPhone4(移动,联通)
	iPhone3,2		iPhone4(联通)
	iPhone3,3		iPhone4(电信)
	iPhone2,1		iPhone3GS
	iPhone1,2		iPhone3G
	iPhone1,1		iPhone

iPad

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
	iPad1,1			iPad1
	iPad2,1			iPad2(Wifi)
	iPad2,2			iPad2(GSM)
	iPad2,3			iPad2(CDMA)
	iPad2,4			iPad2(32nm)
	iPad2,5			iPadmini(Wifi)
	iPad2,6			iPadmini(GSM)
	iPad2,7			iPadmini(CDMA)
	iPad3,1			iPad3(Wifi)
	iPad3,2			iPad3(CDMA)
	iPad3,3			iPad3(4G)
	iPad3,4			iPad4(Wifi)
	iPad3,5			iPad4(4G)
	iPad3,6			iPad4(CDMA)
	iPad4,1			iPadAir
	iPad4,2			iPadAir
	iPad4,3			iPadAir
	iPad4,4			iPadmini2
	iPad4,5			iPadmini2
	iPad4,6			iPadmini2
	iPad4,7			iPadmini3
	iPad4,8			iPadmini3
	iPad4,9			iPadmini3
	iPad5,1			iPadmini4
	iPad5,2			iPadmini4
	iPad5,3			iPadAir2
	iPad5,4			iPadAir2
	iPad6,3			iPadPro(9.7inch)
	iPad6,4			iPadPro(9.7inch)
	iPad6,7			iPadPro(12.9inch)
	iPad6,8			iPadPro(12.9inch)

iPod、AppleTV、AppleWatch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
	iPod6,1			iPodtouch6
	iPod5,1			iPodtouch5
	iPod4,1			iPodtouch4
	iPod3,1			iPodtouch3
	iPod2,1			iPodtouch2
	iPod1,1			iPodtouch
 
	AppleTV2,1		AppleTV2
	AppleTV3,1		AppleTV3
	AppleTV3,2		AppleTV3
	AppleTV5,3		AppleTV4
 
	Watch1,1		AppleWatch
	Watch1,2		AppleWatch

使用参考:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
- (NSString*) getDeviceName
{
    NSString *deviceString = [self getDeviceVersionInfo]
 
    NSArray *modelArray = @[
 
                            @"i386", @"x86_64",
 
                            @"iPhone1,1",
                            @"iPhone1,2",
                            @"iPhone2,1",
                            @"iPhone3,1",
                            @"iPhone3,2",
                            @"iPhone3,3",
                            @"iPhone4,1",
                            @"iPhone5,1",
                            @"iPhone5,2",
                            @"iPhone5,3",
                            @"iPhone5,4",
                            @"iPhone6,1",
                            @"iPhone6,2",
 
                            @"iPod1,1",
                            @"iPod2,1",
                            @"iPod3,1",
                            @"iPod4,1",
                            @"iPod5,1",
 
                            @"iPad1,1",
                            @"iPad2,1",
                            @"iPad2,2",
                            @"iPad2,3",
                            @"iPad2,4",
                            @"iPad3,1",
                            @"iPad3,2",
                            @"iPad3,3",
                            @"iPad3,4",
                            @"iPad3,5",
                            @"iPad3,6",
 
                            @"iPad2,5",
                            @"iPad2,6",
                            @"iPad2,7",
                            ];
    NSArray *modelNameArray = @[
 
                                @"iPhone Simulator", @"iPhone Simulator",
 
                                @"iPhone 2G",
                                @"iPhone 3G",
                                @"iPhone 3GS",
                                @"iPhone 4(GSM)",
                                @"iPhone 4(GSM Rev A)",
                                @"iPhone 4(CDMA)",
                                @"iPhone 4S",
                                @"iPhone 5(GSM)",
                                @"iPhone 5(GSM+CDMA)",
                                @"iPhone 5c(GSM)",
                                @"iPhone 5c(Global)",
                                @"iphone 5s(GSM)",
                                @"iphone 5s(Global)",
 
                                @"iPod Touch 1G",
                                @"iPod Touch 2G",
                                @"iPod Touch 3G",
                                @"iPod Touch 4G",
                                @"iPod Touch 5G",
 
                                @"iPad",
                                @"iPad 2(WiFi)",
                                @"iPad 2(GSM)",
                                @"iPad 2(CDMA)",
                                @"iPad 2(WiFi + New Chip)",
                                @"iPad 3(WiFi)",
                                @"iPad 3(GSM+CDMA)",
                                @"iPad 3(GSM)",
                                @"iPad 4(WiFi)",
                                @"iPad 4(GSM)",
                                @"iPad 4(GSM+CDMA)",
 
                                @"iPad mini (WiFi)",
                                @"iPad mini (GSM)",
                                @"ipad mini (GSM+CDMA)"
                                ];
    NSInteger modelIndex = - 1;
    NSString *modelNameString = nil;
    modelIndex = [modelArray indexOfObject:deviceString];
    if (modelIndex >= 0 && modelIndex < [modelNameArray count]) {
        modelNameString = [modelNameArray objectAtIndex:modelIndex];
    }
 
    NSLog(@"----设备类型---%@",modelNameString);
    return modelNameString;
}