-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIDeviceHardware.m
More file actions
49 lines (40 loc) · 1.63 KB
/
UIDeviceHardware.m
File metadata and controls
49 lines (40 loc) · 1.63 KB
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
//
// UIDeviceHardware.m
//
// Used to determine EXACT version of device software is running on.
#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;
}
+ (NTDDevicePerformanceClass) performanceClass {
// reference: http://ios.e-lite.org/
NSString *platformString = [UIDeviceHardware platform];
// NSSets are faster for finding objects
NSSet *lowPerformanceDeviceStrings = [NSSet setWithObjects:@"iPhone1,1",
@"iPhone1,2",
@"iPhone2,1",
@"iPhone3,1",
@"iPhone3,2",
@"iPhone3,3",
@"iPod1,1",
@"iPod2,1",
@"iPod3,1",
@"iPod4,1",
@"iPad1,1",
@"iPad2,1",
@"iPad2,2",
@"iPad2,3", nil];
if ([lowPerformanceDeviceStrings containsObject:platformString])
return NTDLowPerformanceDevice;
return NTDHighPerformanceDevice;
}
@end