According to your question, I assume that you want to identify a hardware device, not an iOS version.
#include <sys/sysctl.h> NSString* getSysInfoByName(char* typeSpecifier) { size_t size; sysctlbyname(typeSpecifier, NULL, &size, NULL, 0); char *answer = malloc(size); sysctlbyname(typeSpecifier, answer, &size, NULL, 0); NSString *results = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding]; free(answer); return results; } NSString* platform() { return getSysInfoByName("hw.machine"); }
Import these functions into .pch, then you can call this one liner:
BOOL isIphone5 = [platform() hasPrefix:@"iPhone5"];
It works for any device. See UIDevice-Hardware.m for a list of returned rows.
source share