Get iOS device name/Resolution

Source: Internet
Author: User

https://github.com/svgkit/svgkit//svgkit -> svglength.m         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); if ( [ platform hasprefix:@ "IPhone1"]| |  [platform hasprefix:@ "IPhone2"]| |  [platform hasprefix:@ "IPhone3"]) return 163.0f;if ( [platform hasprefix:@ "IPhone4"]| |  [platform hasprefix:@ "IPhone5"]| |  [platform hasprefix:@ "IPhone6"]) return 326.0f;             // for iphone6+    // added by gerry  2014.11.22 10:12    //    // Note: iPhone6   326ppi    if ( [platform hasprefix:@ "IPhone7")  {         return 401.0f;    }if ( [platform hasprefix:@ "IPhone "])  // catch-all for higher-end devices not yet existing{nsassert ( false, @ "not supported yet: you are using an iphone that  Didn ' T exist when this code was written, we have no idea  what the pixel count per inch is! "); return 326.0f;} if ( [platform hasprefix:@ "IPod1"]   | |  [platform hasprefix:@ "IPod2"]   | |  [platform hasprefix:@ "IPod3"]) return 163.0f;if ( [platform hasprefix:@ "IPOD4"]    | |  [platform hasprefix:@ "IPOD5"]) return 326.0f;if ( [platform hasprefix:@ "IPod"])  / / catch-all&Nbsp;for higher-end devices not yet existing{nsassert (FALSE, @ "Not  Supported yet: you are using an ipod that didn ' T exist when  this code was written, we have no idea what the pixel  count per inch is! "); return 326.0f;} if ( [platform hasprefix:@ "IPad1"]| |  [platform hasprefix:@ "IPad2"]) return 132.0f;if ( [platform hasprefix:@ "IPad3"]| |  [platform hasprefix:@ "IPad4"]) return 264.0f;if ( [platform hasprefix:@ "IPad"])  / / catch-all for higher-end devices not yet existing{nsassert (FALSE, @ " Not supported yet: you are using an ipad that didn ' T exist  when this code was written, we have no idea what the  pixel count per&Nbsp;inch is! "); return 264.0f;} if ( [platform hasprefix:@ "x86_64"]) {Ddlogwarn (@ "[%@] warning: you are running  on the simulator; it ' s impossible for us to calculate  Centimeter/millimeter/inches units correctly ",  [self class]); return 132.0f; //  simulator, running on desktop machine}


Get iOS device name/Resolution

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.