-
-
Save lbrndnr/1239394 to your computer and use it in GitHub Desktop.
PSIsCrappyDevice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL PSIsCrappyDevice() { | |
static BOOL isCrappyDevice = YES; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
size_t size; | |
sysctlbyname("hw.machine", NULL, &size, NULL, 0); | |
char *machine = malloc(size); | |
sysctlbyname("hw.machine", machine, &size, NULL, 0); | |
NSString *platform = [[NSString alloc] initWithCString:machine]; | |
free(machine); | |
isCrappyDevice = !(![platform hasPrefix:@"iP"] || [platform hasPrefix:@"iPhone3"] || [platform isEqualToString:@"iPod4,1"] || [platform hasPrefix:@"iPad2"]); | |
[platform release]; | |
}); | |
return isCrappyDevice; | |
} |
While checking for strings might not be a good idea, checking for aspects might break as easily. While it might never happen, just imagine the next iPad having neither Retina nor Camera, or a new device falling into this category - checking for aspects breaks and treats this device as a crappy device.
How high are the odds for apple DOWNGRADING from retina? If so, it sure must be a crappy device ;)
But true... neither is perfect.
Not all current devices have retina, so I wouldn't consider it a downgrade. There might be room for a cheaper model of the next iPhone/iPad, and we never know the specs. There's definitely neither of the methods perfect, I'm just not sure what's easier to break (so which method I should add to iOSKit :) ).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's usually not a good idea to explicitely check for STRINGS for a platform. Much better to search for aspects. You want your code be future proof.