Based on the answers to this question, you can determine which model you are using thereby:
NSString *deviceModel = [UIDevice currentDevice].model;
The results can be one of the values: iPod touch, iPhone, iPad, iPhone Simulator, iPad Simulator
For a particular model, which version you are using can be determined by creating the Category on UIDevice.h as follows:
UIDevice + Utilities.h
UIDevice + Utilities.m
#import "UIDevice+Utilities.h" #include <sys/types.h> #include <sys/sysctl.h> @implementation UIDevice (Utilities) - (CGFloat)deviceModelVersion { size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); char *machine = malloc(size); sysctlbyname("hw.machine", machine, &size, NULL, 0); NSString *platform = [NSString stringWithUTF8String:machine]; free(machine); if ([platform rangeOfString:@"iPhone"].location != NSNotFound) { return [[[platform stringByReplacingOccurrencesOfString:@"iPhone" withString:@""] stringByReplacingOccurrencesOfString:@"," withString:@"."] floatValue]; } else if ([platform rangeOfString:@"iPad"].location != NSNotFound) { return [[[platform stringByReplacingOccurrencesOfString:@"iPad" withString:@""] stringByReplacingOccurrencesOfString:@"," withString:@"."] floatValue]; } else if ([platform rangeOfString:@"iPod"].location != NSNotFound) { return [[[platform stringByReplacingOccurrencesOfString:@"iPod" withString:@""] stringByReplacingOccurrencesOfString:@"," withString:@"."] floatValue]; } else if ([platform rangeOfString:@"i386"].location != NSNotFound || [platform rangeOfString:@"x86_64"].location != NSNotFound) { return -1.0; //Currently it is not possible (or maybe it is, but I do not know) //which type of simulator device model version your app is running //so I am returning -1.0 device model version for all simulators types } return 0.0; } @end
An example of calling the deviceModelVersion function:
CGFloat deviceModelVersion = [UIDevice currentDevice].deviceModelVersion;
Possible results can be 1.0, 1.1, ..., 2.0, 2.1, ..., 3.0, 3.1, .., 4.0, 4.1, .., 5.0, 5.1, ...
To determine if this is an iPhone 5, you will have
deviceModel : "iPhone"
and
deviceModelVersion : >=5.0 and < 6.0