Created
February 7, 2015 01:16
-
-
Save jhurliman/aba2ed3eca936e9b8510 to your computer and use it in GitHub Desktop.
isIPhone6OrNewer.m
This file contains hidden or 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
#include <sys/utsname.h> | |
+ (BOOL)isIPhone6OrNewer | |
{ | |
static int major = -1; | |
if (major == -1) { | |
struct utsname unameData; | |
if (0 != uname(&unameData)) { | |
major = 0; | |
} else { | |
NSString *code = [NSString stringWithCString:unameData.machine | |
encoding:NSUTF8StringEncoding]; | |
if ([code hasPrefix:@"iPhone"]) | |
major = [code substringWithRange:NSMakeRange(6, 1)].intValue; | |
else | |
major = 0; | |
} | |
} | |
return major >= 7; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment