How to check if an iOS device is a retina display iPod touch?
-
26-06-2021 - |
Question
Is there a safe way to determine that a device is of a particular model? For example I must know if the device the user uses is a retina display iPod touch.
Solution
NSRange r = [[[UIDevice currentDevice] model] rangeOfString:@"iPod"];
float s = [[UIScreen mainScreen] scale];
if (r.location != NSNotFound && s > 1.5f) {
// retina iTouch
}
OTHER TIPS
I would probably try something like this:
+(BOOL) isRetinaiPod
{
return [[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"] && [UIScreen mainScreen].scale >= 2.0f;
}
However you can return the device's name with this:
+ (NSString *) deviceName
{
struct utsname u;
uname(&u);
return [NSString stringWithUTF8String:u.sysname];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow