I need to know which iOS device is currently running app (saying more exactly I need to know is device armv6 or armv7). UIUserInterfaceIdiomPad() could not check is device an iPhone4S or iPhone3G. Is it possible?
Asked
Active
Viewed 1.3k times
3
-
Just out of curiosity, why do you need to know whether it is armv6 or armv7? – Nick Bull Jun 18 '12 at 11:34
-
I've added some feature into my project, and it causes crashes on armv6 devices (iPhone3G). I know, that the problem is in processor's architecture, but could not figure out how to solve it yet. So I decided to make a switch which turns off this feature on old devices while I'm trying to make app run on all devices – medvedNick Jun 18 '12 at 11:45
2 Answers
11
Download https://github.com/erica/uidevice-extension (UIDevice-Hardware class) and you can use these:
[UIDevice currentDevice] platformType] // returns UIDevice4GiPhone
[[UIDevice currentDevice] platformString] // returns @"iPhone 4G"
Or check if its retina
+ (BOOL) isRetina
{
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
return [[UIScreen mainScreen] scale] == 2.0 ? YES : NO;
return NO;
}
Or check iOs version
+ (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;
}
Stunner
- 12,025
- 12
- 86
- 145
Omar Abdelhafith
- 21,163
- 5
- 52
- 56
-
thanks! that and @Michael Dautermann's answer is exactly what I needed! – medvedNick Jun 18 '12 at 11:39
-
hmm you did not say that -platformString is an category for uidevice from [there](https://github.com/erica/uidevice-extension/) ;) – medvedNick Jun 18 '12 at 12:03
-
1
-
I forgot to mention that you have to download this https://github.com/erica/uidevice-extension/ – Omar Abdelhafith Jul 01 '12 at 05:58
-
1Revoked my -1 and edited your post to post the url at the top with the code block (more helpful at a glance that way). – Stunner Jul 06 '12 at 03:09
1
If you really want to know (at run time) if you are running on arm6 or arm7, you can use "NXGetArchInfoFromCPUType" (much more detail is available in the accepted answer to this question).
Otherwise you can use platformType or platformString, as our incredibly quick answering friend Omar suggested (and +1 to him!).
Community
- 1
- 1
Michael Dautermann
- 88,797
- 17
- 166
- 215
-
1did I say aggressive? what I meant was "darn, you're super fast in answering". Probably another month or so and you'll catch up to me in terms of points. – Michael Dautermann Jun 18 '12 at 11:38
-
thanks for the link, it will be really helpful! and you are both quick in answering, by the way – medvedNick Jun 18 '12 at 11:40
-
@MichaelDautermann i wish i could reach 10K thanks for the encouragement :) ,medvedNick you are welcome – Omar Abdelhafith Jun 18 '12 at 11:42