ios - Identify iphone's version -
i'm developing app can installed in iphone 4 , later versions.i go through uirequireddevicecapabilities , device compatibility matrix.i need more solution.
well, first of can receive model string using uidevice
class:
[[uidevice currentdevice] model]
this return "ipod touch" or "iphone".
you can exact model platform using following code:
(you have #include <sys/types.h>
, <sys/sysctl.h>
)
size_t size; sysctlbyname("hw.machine", null, &size, null, 0); char *machine = malloc(size); sysctlbyname("hw.machine", machine, &size, null, 0); nsstring *platform = @(machine); // old syntax: [nsstring stringwithcstring:machine encoding:nsutf8stringencoding] free(machine);
now platform
string containing generation of device, e.g.:
iphone1,1
iphone 2g (the first iphone)iphone1,2
iphone 3giphone2,1
iphone 3gsiphone3,1
oriphone3,2
iphone 4iphone4,1
iphone 4siphone5,1
oriphone5,2
iphone 5
note number in front of comma of iphone 4 platform 3, not 4. using string can isolate number , check if greater or equal 3:
if ([[[uidevice currentdevice] model] isequaltostring:@"iphone"]) { if ([[[platform componentsseparatedbystring:@","][0] substringfromindex:6] intvalue] >= 3) { // device iphone 4 or newer } else { // device older iphone 4 } }
however: can check screen's scale, since iphone 4 first iphone retina display:
[[uiscreen mainscreen] scale] // returns 2.0f on iphone 4 , newer , 1.0f on older devices
Comments
Post a Comment