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?
How to detect iOS device programmatically
Just out of curiosity, why do you need to know whether it is armv6 or armv7? –
Austenite
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 –
Mustard
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;
}
thanks! that and @Michael Dautermann's answer is exactly what I needed! –
Mustard
hmm you did not say that -platformString is an category for uidevice from there ;) –
Mustard
-1
[[UIDevice currentDevice] platformString]
didn't work for me. –
Wilbertwilborn I forgot to mention that you have to download this github.com/erica/uidevice-extension –
Pensile
Revoked my -1 and edited your post to post the url at the top with the code block (more helpful at a glance that way). –
Wilbertwilborn
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!).
did 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. –
Weirick
thanks for the link, it will be really helpful! and you are both quick in answering, by the way –
Mustard
@MichaelDautermann i wish i could reach 10K thanks for the encouragement :) ,medvedNick you are welcome –
Pensile
© 2022 - 2024 — McMap. All rights reserved.