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