[IOS] Get the specific device model information

Source: Internet
Author: User

[IOS] Get the specific device model information

Address; http://blog.csdn.net/zhaoyabei/article/details/46697859
In application statistics, you sometimes need to upload the device model:

[[UIDevice currentDevice] model]

The device model obtained is not a specific model. For example, if you run it on the iPhone 5S, the measured string is @ "iPhone". What I want is a specific model.
Here we provide a method to obtain the specific device model (the correspondence between the version and model comes from Wikipedia ):

-(NSString *) platform {struct utsname systemInfo; uname (& systemInfo); NSString * deviceString = [NSString stringWithCString: systemInfo. machine encoding: NSUTF8StringEncoding]; // older devices such as iPhone 3 are not considered, and iPad devices are not considered (the company's applications do not support iPad) if ([deviceString hasPrefix: @ iPhone3]) return @ iPhone 4; if ([deviceString isEqualToString: @ iPhone4, 1]) return @ iPhone 4S; if ([deviceString isEqualToString: @ iPhone5, 1] | [deviceString isEqualToString: @ iPhone5, 2]) return @ iPhone 5; if ([deviceString isEqualToString: @ iPhone5, 3] | [deviceString isEqualToString: @ iPhone5, 4]) return @ iPhone 5C; if ([deviceString hasPrefix: @ iPhone6]) return @ iPhone 5S; if ([deviceString isEqualToString: @ iPhone7, 1]) return @ iPhone 6 Plus; if ([deviceString is: tostring: @ iPhone7, 2]) return @ iPhone 6; if ([deviceString isEqualToString: @ i386]) return @ Simulator; if ([deviceString isEqualToString: @ x86_64]) return @ Simulator; // if no match exists, return the type "return deviceString" provided by the system, such as @ iPhone5 and 3 ;}

 

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.