iOS development-Get device model information

Source: Internet
Author: User

Some time in development to view the design statistics, or through the log to see the error message, this time we need to obtain information about the device, there are several ways to see the device:

    NSLog (@ "%@", [[[Uidevice Currentdevice] name]);//Device name    NSLog (@ "%@", [[Uidevice Currentdevice] model]);//device Type    NSLog (@ "%@", [[Uidevice Currentdevice] localizedmodel]);    NSLog (@ "%@", [[Uidevice Currentdevice] systemName]);//System name    NSLog (@ "%@", [[Uidevice Currentdevice] systemversion] );//System version

This does not meet our needs, we need to obtain specific equipment models, iPhone4 or iphone6s,32g or 64G, we need to expand their own uidevice, before the actual combat we need to look at the Wikipedia document: https:// Www.theiphonewiki.com/wiki/Models;

+ (NSString *) deviceplatform{struct utsname systemInfo;    Uname (&systeminfo);    NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:nsutf8stringencoding];    if ([Platform isequaltostring:@ "iphone3,1"]) return @ "IPhone 4 (A1332)";    if ([Platform isequaltostring:@ "iphone3,2"]) return @ "IPhone 4 (A1332)";    if ([Platform isequaltostring:@ "iphone3,3"]) return @ "IPhone 4 (A1349)";    if ([Platform isequaltostring:@ "iphone4,1"]) return @ "IPhone 4S (a1387/a1431)";    if ([Platform isequaltostring:@ "iphone5,1"]) return @ "IPhone 5 (A1428)";    if ([Platform isequaltostring:@ "iphone5,2"]) return @ "IPhone 5 (a1429/a1442)";    if ([Platform isequaltostring:@ "iphone5,3"]) return @ "IPhone 5c (a1456/a1532)";    if ([Platform isequaltostring:@ "iphone5,4"]) return @ "IPhone 5c (a1507/a1516/a1526/a1529)";    if ([Platform isequaltostring:@ "iphone6,1"]) return @ "IPhone 5s (a1453/a1533)"; if ([Platform isequaltostring:@ "iphone6,2"]) return @ "IPhone 5s (a1457/a1518/a1528/a1530) ";    if ([Platform isequaltostring:@ "iphone7,1"]) return @ "IPhone 6 Plus (a1522/a1524)";    if ([Platform isequaltostring:@ "iphone7,2"]) return @ "IPhone 6 (a1549/a1586)";    http://www.cnblogs.com/xiaofeixiang/if ([Platform isequaltostring:@ "ipod1,1"]) return @ "IPod Touch 1G (A1213)";    if ([Platform isequaltostring:@ "ipod2,1"]) return @ "IPod Touch 2G (A1288)";    if ([Platform isequaltostring:@ "ipod3,1"]) return @ "IPod Touch 3G (A1318)";    if ([Platform isequaltostring:@ "ipod4,1"]) return @ "IPod Touch 4G (A1367)";        if ([Platform isequaltostring:@ "ipod5,1"]) return @ "IPod Touch 5G (a1421/a1509)";        if ([Platform isequaltostring:@ "ipad1,1"]) return @ "IPad 1G (a1219/a1337)";    if ([Platform isequaltostring:@ "ipad2,1"]) return @ "IPad 2 (A1395)";    if ([Platform isequaltostring:@ "ipad2,2"]) return @ "IPad 2 (A1396)";    if ([Platform isequaltostring:@ "ipad2,3"]) return @ "IPad 2 (A1397)"; if ([Platform isequaltostring:@ "ipad2,4"]) RetuRN @ "IPad 2 (a1395+new Chip)";    if ([Platform isequaltostring:@ "ipad2,5"]) return @ "IPad Mini 1G (A1432)";    if ([Platform isequaltostring:@ "ipad2,6"]) return @ "IPad Mini 1G (A1454)";        if ([Platform isequaltostring:@ "ipad2,7"]) return @ "IPad Mini 1G (A1455)";    if ([Platform isequaltostring:@ "ipad3,1"]) return @ "IPad 3 (A1416)";    if ([Platform isequaltostring:@ "ipad3,2"]) return @ "IPad 3 (A1403)";    if ([Platform isequaltostring:@ "ipad3,3"]) return @ "IPad 3 (A1430)";    if ([Platform isequaltostring:@ "ipad3,4"]) return @ "IPad 4 (A1458)";    if ([Platform isequaltostring:@ "ipad3,5"]) return @ "IPad 4 (A1459)";        if ([Platform isequaltostring:@ "ipad3,6"]) return @ "IPad 4 (A1460)";    if ([Platform isequaltostring:@ "ipad4,1"]) return @ "IPad Air (A1474)";    if ([Platform isequaltostring:@ "ipad4,2"]) return @ "IPad Air (A1475)";    if ([Platform isequaltostring:@ "ipad4,3"]) return @ "IPad Air (A1476)"; if ([Platform isequaltostring:@ "ipad4,4"]) rEturn @ "IPad Mini 2G (A1489)";    if ([Platform isequaltostring:@ "ipad4,5"]) return @ "IPad Mini 2G (A1490)";        if ([Platform isequaltostring:@ "ipad4,6"]) return @ "IPad Mini 2G (A1491)";    if ([Platform isequaltostring:@ "i386"]) return @ "IPhone Simulator";    if ([Platform isequaltostring:@ "x86_64"]) return @ "IPhone Simulator"; return platform;}

Parameter information can be added through Wikipedia, if only to determine the iphone generations can also be confirmed by the screen resolution ~

iOS development-Get device model information

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.