Obtain the latest and most complete device numbers (including iPhone 6 and iPhone 6 plus)
# Include
# Include
@ Implementation DeviceManager
+ (NSString *) getDeviceVersion
{
Size_t size;
Sysctlbyname ("hw. machine", NULL, & size, NULL, 0 );
Char * machine = (char *) malloc (size );
Sysctlbyname ("hw. machine", machine, & size, NULL, 0 );
NSString * platform = [NSStringstringWithCString: machineencoding: NSUTF8StringEncoding];
// NSString * platform = [nsstringstringwithuf8string: machine]; the two are equivalent
Free (machine );
Return platform;
}
+ (NSString *) getPlatformString
{
NSString * platform = [selfgetDeviceVersion];
// IPhone
If ([platformisEqualToString: @ "iPhone1, 1"]) return @ "iPhone 1 ";
If ([platformisEqualToString: @ "iPhone1, 2"]) return @ "iPhone 3 ";
If ([platformisEqualToString: @ "iPhone2, 1"]) return @ "iPhone 3GS ";
If ([platformisEqualToString: @ "iPhone3, 1"]) return @ "iPhone 4 ";
If ([platformisEqualToString: @ "iPhone3, 2"]) return @ "iPhone 4 ";
If ([platformisEqualToString: @ "iPhone3, 3"]) return @ "iPhone 4 ";
If ([platformisEqualToString: @ "iPhone4, 1"]) return @ "iPhone 4 s ";
If ([platformisEqualToString: @ "iPhone5, 1"]) return @ "iPhone 5 ";
If ([platformisEqualToString: @ "iPhone5, 2"]) return @ "iPhone 5 ";
If ([platformisEqualToString: @ "iPhone5, 3"]) return @ "iPhone 5C ";
If ([platformisEqualToString: @ "iPhone5, 4"]) return @ "iPhone 5C ";
If ([platformisEqualToString: @ "iPhone6, 1"]) return @ "iPhone 5 S ";
If ([platformisEqualToString: @ "iPhone6, 2"]) return @ "iPhone 5 S ";
If ([platformisEqualToString: @ "iPhone7, 1"]) return @ "iPhone 6 ";
If ([platformisEqualToString: @ "iPhone7, 2"]) return @ "iPhone 6 Plus ";
// IPot Touch
If ([platformisEqualToString: @ "iPod1, 1"]) return @ "iPod Touch ";
If ([platformisEqualToString: @ "iPod2, 1"]) return @ "iPod Touch 2 ";
If ([platformisEqualToString: @ "iPod3, 1"]) return @ "iPod Touch 3 ";
If ([platformisEqualToString: @ "iPod4, 1"]) return @ "iPod Touch 4 ";
If ([platformisEqualToString: @ "iPod5, 1"]) return @ "iPod Touch 5 ";
// IPad
If ([platformisEqualToString: @ "iPad1, 1"]) return @ "iPad ";
If ([platformisEqualToString: @ "iPad2, 1"]) return @ "iPad 2 ";
If ([platformisEqualToString: @ "iPad2, 2"]) return @ "iPad 2 ";
If ([platformisEqualToString: @ "iPad2, 3"]) return @ "iPad 2 ";
If ([platformisEqualToString: @ "iPad2, 4"]) return @ "iPad 2 ";
If ([platformisEqualToString: @ "iPad2, 5"]) return @ "iPad Mini 1 ";
If ([platformisEqualToString: @ "iPad2, 6"]) return @ "iPad Mini 1 ";
If ([platformisEqualToString: @ "iPad2, 7"]) return @ "iPad Mini 1 ";
If ([platformisEqualToString: @ "iPad3, 1"]) return @ "iPad 3 ";
If ([platformisEqualToString: @ "iPad3, 2"]) return @ "iPad 3 ";
If ([platformisEqualToString: @ "iPad3, 3"]) return @ "iPad 3 ";
If ([platformisEqualToString: @ "iPad3, 4"]) return @ "iPad 4 ";
If ([platformisEqualToString: @ "iPad3, 5"]) return @ "iPad 4 ";
If ([platformisEqualToString: @ "iPad3, 6"]) return @ "iPad 4 ";
If ([platformisEqualToString: @ "iPad4, 1"]) return @ "iPad air ";
If ([platformisEqualToString: @ "iPad4, 2"]) return @ "iPad air ";
If ([platformisEqualToString: @ "iPad4, 3"]) return @ "iPad air ";
If ([platformisEqualToString: @ "iPad4, 4"]) return @ "iPad mini 2 ";
If ([platformisEqualToString: @ "iPad4, 5"]) return @ "iPad mini 2 ";
If ([platformisEqualToString: @ "iPad4, 6"]) return @ "iPad mini 2 ";
If ([platformisEqualToString: @ "iPad4, 7"]) return @ "iPad mini 3 ";
If ([platformisEqualToString: @ "iPad4, 8"]) return @ "iPad mini 3 ";
If ([platformisEqualToString: @ "iPad4, 9"]) return @ "iPad mini 3 ";
If ([platformisEqualToString: @ "iPad5, 3"]) return @ "iPad air 2 ";
If ([platformisEqualToString: @ "iPad5, 4"]) return @ "iPad air 2 ";
If ([platformisEqualToString: @ "iPhone Simulator"] | [platformisEqualToString: @ "x86_64"]) return @ "iPhone Simulator ";
Return platform;
}