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 3g
  • iphone2,1 iphone 3gs
  • iphone3,1 or iphone3,2 iphone 4
  • iphone4,1 iphone 4s
  • iphone5,1 or iphone5,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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -