How to programmatically identify an iOS device

I need to know which iOS device is currently working (more precisely, I need to know the armv6 or armv7 device). UIUserInterfaceIdiomPad () could not verify the iPhone4S or iPhone3G device. Is it possible?

+3
source share
2 answers

Download https://github.com/erica/uidevice-extension (UIDevice-Hardware class) and you can use them:

[UIDevice currentDevice] platformType] // returns UIDevice4GiPhone [[UIDevice currentDevice] platformString] // returns @"iPhone 4G" 

Or check if his retina

 + (BOOL) isRetina { if([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) return [[UIScreen mainScreen] scale] == 2.0 ? YES : NO; return NO; } 

Or check the version of iOs

 + (BOOL) isIOS5 { NSString *os5 = @"5.0"; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; // currSysVer = @"5.0.1"; if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedAscending) //lower than 4 { return NO; } else if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) //5.0.1 and above { return YES; } else // IOS 5 { return YES; } return NO; } 
+11
source

If you really want to find out (at runtime) if you are working on arm6 or arm7, you can use " NXGetArchInfoFromCPUType " ( much more details are available in the accepted answer this question ).

Otherwise, you can use platformType or platformString, as our incredibly fast reciprocal friend Omar suggested (and +1 to him!).

+1
source

All Articles