Skip to content

Instantly share code, notes, and snippets.

@jhurliman
Created February 7, 2015 01:16
Show Gist options
  • Save jhurliman/aba2ed3eca936e9b8510 to your computer and use it in GitHub Desktop.
Save jhurliman/aba2ed3eca936e9b8510 to your computer and use it in GitHub Desktop.
isIPhone6OrNewer.m
#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