This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathUIDeviceHardware.m
136 lines (127 loc) · 8.73 KB
/
UIDeviceHardware.m
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
// UIDeviceHardware.m
//
// usage :
// NSString *platform = [UIDeviceHardware platform];
//
#import "UIDeviceHardware.h"
#include <sys/types.h>
#include <sys/sysctl.h>
@implementation UIDeviceHardware
+ (NSString *) platform{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
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 (GSM)";
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 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (CDMA)";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s";
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:@"iPhone10,1"]) return @"iPhone 8";
if ([platform isEqualToString:@"iPhone10,2"]) return @"iPhone 8 Plus";
if ([platform isEqualToString:@"iPhone10,3"]) return @"iPhone X";
if ([platform isEqualToString:@"iPhone10,4"]) return @"iPhone 8";
if ([platform isEqualToString:@"iPhone10,5"]) return @"iPhone 8 Plus";
if ([platform isEqualToString:@"iPhone10,6"]) return @"iPhone X";
if ([platform isEqualToString:@"iPhone11,2"]) return @"iPhone XS";
if ([platform isEqualToString:@"iPhone11,4"]) return @"iPhone XS Max";
if ([platform isEqualToString:@"iPhone11,6"]) return @"iPhone XS Max";
if ([platform isEqualToString:@"iPhone11,8"]) return @"iPhone XR";
if ([platform isEqualToString:@"iPhone12,1"]) return @"iPhone 11";
if ([platform isEqualToString:@"iPhone12,3"]) return @"iPhone 11 Pro";
if ([platform isEqualToString:@"iPhone12,5"]) return @"iPhone 11 Pro Max";
if ([platform isEqualToString:@"iPhone12,8"]) return @"iPhone SE 2";
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:@"iPod7,1"]) return @"iPod Touch 6G";
if ([platform isEqualToString:@"iPod9,1"]) return @"iPod Touch 7G";
if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2 (GSM)";
if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini (GSM)";
if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini (CDMA)";
if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (CDMA)";
if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3 (GSM)";
if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4 (GSM)";
if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (CDMA)";
if ([platform isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)";
if ([platform isEqualToString:@"iPad4,2"]) return @"iPad Air (GSM)";
if ([platform isEqualToString:@"iPad4,3"]) return @"iPad Air (CDMA)";
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 (Cellular)";
if ([platform isEqualToString:@"iPad4,7"]) return @"iPad Mini 3 (WiFi)";
if ([platform isEqualToString:@"iPad4,8"]) return @"iPad Mini 3 (Cellular)";
if ([platform isEqualToString:@"iPad4,9"]) return @"iPad Mini 3 (Cellular)";
if ([platform isEqualToString:@"iPad5,1"]) return @"iPad Mini 4 (WiFi)";
if ([platform isEqualToString:@"iPad5,2"]) return @"iPad Mini 4 (Cellular)";
if ([platform isEqualToString:@"iPad5,3"]) return @"iPad Air 2 (WiFi)";
if ([platform isEqualToString:@"iPad5,4"]) return @"iPad Air 2 (Cellular)";
if ([platform isEqualToString:@"iPad6,3"]) return @"iPad Pro 9.7-inch (WiFi)";
if ([platform isEqualToString:@"iPad6,4"]) return @"iPad Pro 9.7-inch (Cellular)";
if ([platform isEqualToString:@"iPad6,7"]) return @"iPad Pro 12.9-inch (WiFi)";
if ([platform isEqualToString:@"iPad6,8"]) return @"iPad Pro 12.9-inch (Cellular)";
if ([platform isEqualToString:@"iPad6,11"]) return @"iPad 5 (WiFi)";
if ([platform isEqualToString:@"iPad6,12"]) return @"iPad 5 (Cellular)";
if ([platform isEqualToString:@"iPad7,1"]) return @"iPad Pro 12.9-inch 2 (WiFi)";
if ([platform isEqualToString:@"iPad7,2"]) return @"iPad Pro 12.9-inch 2 (Cellular)";
if ([platform isEqualToString:@"iPad7,3"]) return @"iPad Pro 10.5-inch (WiFi)";
if ([platform isEqualToString:@"iPad7,4"]) return @"iPad Pro 10.5-inch (Cellular)";
if ([platform isEqualToString:@"iPad7,5"]) return @"iPad 6 (WiFi)";
if ([platform isEqualToString:@"iPad7,6"]) return @"iPad 6 (Cellular)";
if ([platform isEqualToString:@"iPad7,11"]) return @"iPad 7 (WiFi)";
if ([platform isEqualToString:@"iPad7,12"]) return @"iPad 7 (Cellular)";
if ([platform isEqualToString:@"iPad8,1"]) return @"iPad Pro 11-inch (WiFi)";
if ([platform isEqualToString:@"iPad8,2"]) return @"iPad Pro 11-inch (WiFi, 1TB)";
if ([platform isEqualToString:@"iPad8,3"]) return @"iPad Pro 11-inch (Cellular)";
if ([platform isEqualToString:@"iPad8,4"]) return @"iPad Pro 11-inch (Cellular, 1TB)";
if ([platform isEqualToString:@"iPad8,5"]) return @"iPad Pro 12.9-inch 3 (WiFi)";
if ([platform isEqualToString:@"iPad8,6"]) return @"iPad Pro 12.9-inch 3 (WiFi, 1TB)";
if ([platform isEqualToString:@"iPad8,7"]) return @"iPad Pro 12.9-inch 3 (Cellular)";
if ([platform isEqualToString:@"iPad8,8"]) return @"iPad Pro 12.9-inch 3 (Cellular, 1TB)";
if ([platform isEqualToString:@"iPad8,9"]) return @"iPad Pro 11-inch 2 (WiFi)";
if ([platform isEqualToString:@"iPad8,10"]) return @"iPad Pro 11-inch 2 (Cellular)";
if ([platform isEqualToString:@"iPad8,11"]) return @"iPad Pro 12.9-inch 4 (WiFi)";
if ([platform isEqualToString:@"iPad8,12"]) return @"iPad Pro 12.9-inch 4 (Cellular)";
if ([platform isEqualToString:@"iPad11,1"]) return @"iPad Mini 5 (WiFi)";
if ([platform isEqualToString:@"iPad11,2"]) return @"iPad Mini 5 (Cellular)";
if ([platform isEqualToString:@"iPad11,3"]) return @"iPad Air 3 (WiFi)";
if ([platform isEqualToString:@"iPad11,4"]) return @"iPad Air 3 (Cellular)";
if ([platform isEqualToString:@"iPad13,1"]) return @"iPad Air 4 (WiFi)";
if ([platform isEqualToString:@"iPad13,2"]) return @"iPad Air 4 (Cellular)";
if ([platform isEqualToString:@"i386"]) return [UIDevice currentDevice].model;
if ([platform isEqualToString:@"x86_64"]) return [UIDevice currentDevice].model;
return platform;
}
@end