Obtain the latest and most complete device numbers (including iPhone 6 and iPhone 6 plus)

Source: Internet
Author: User

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;

}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.