I am working on app which needs to check the iphone model, but I\'m not able to find any solution. I will be thank full for any suggestion.
Use this code. This is a full list of any actual iDevice and the Model number, the list can be updated easily by checking http://theiphonewiki.com/wiki/Models .
#import <sys/utsname.h>
struct utsname systemInfo;
uname(&systemInfo);
NSString *modelName = [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
NSString *machinename = [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
NSString *modelnumber = @"?";
//Simulator
if([modelName isEqualToString:@"i386"] || [modelName isEqualToString:@"x86_64"]) {
modelName = @"iPhone Simulator";
}
//iPhone
else if([modelName isEqualToString:@"iPhone1,1"]) {
modelName = @"iPhone";
modelnumber = @"A1203";
}
else if([modelName isEqualToString:@"iPhone1,2"]) {
modelName = @"iPhone 3G";
modelnumber = @"A1241/A1324";
}
else if([modelName isEqualToString:@"iPhone2,1"]) {
modelName = @"iPhone 3GS";
modelnumber = @"A1303/A1325";
}
else if([modelName isEqualToString:@"iPhone3,1"]) {
modelName = @"iPhone 4 (GSM)";
modelnumber = @"A1332";
}
else if([modelName isEqualToString:@"iPhone3,2"]) {
modelName = @"iPhone 4 GSM Rev A";
modelnumber = @"?";
}
else if([modelName isEqualToString:@"iPhone3,3"]) {
modelName = @"iPhone 4 (CDMA)";
modelnumber = @"A1349";
}
else if([modelName isEqualToString:@"iPhone4,1"]) {
modelName = @"iPhone 4S";
modelnumber = @"A1387/A1431";
}
else if([modelName isEqualToString:@"iPhone5,1"]) {
modelName = @"iPhone 5 (GSM)";
modelnumber = @"A1428";
}
else if([modelName isEqualToString:@"iPhone5,2"]) {
modelName = @"iPhone 5 (GSM+CDMA)";
modelnumber = @"A1429/A1442";
}
//iPod touch
else if([modelName isEqualToString:@"iPod1,1"]) {
modelName = @"iPod touch 1G";
modelnumber = @"A1213";
}
else if([modelName isEqualToString:@"iPod2,1"]) {
modelName = @"iPod touch 2G";
modelnumber = @"A1288";
}
else if([modelName isEqualToString:@"iPod3,1"]) {
modelName = @"iPod touch 3G";
modelnumber = @"A1318";
}
else if([modelName isEqualToString:@"iPod4,1"]) {
modelName = @"iPod touch 4G";
modelnumber = @"A1367";
}
else if([modelName isEqualToString:@"iPod5,1"]) {
modelName = @"iPod touch 5G";
modelnumber = @"A1421";
}
//iPad
else if([modelName isEqualToString:@"iPad1,1"]) {
modelName = @"iPad 1G";
modelnumber = @"A1219/A1337";
}
else if([modelName isEqualToString:@"iPad2,1"]) {
modelName = @"iPad 2 (WiFi)";
modelnumber = @"A1395";
}
else if([modelName isEqualToString:@"iPad2,2"]) {
modelName = @"iPad 2 (GSM)";
modelnumber = @"A1396";
}
else if([modelName isEqualToString:@"iPad2,3"]) {
modelName = @"iPad 2 (CDMA)";
modelnumber = @"A1397";
}
else if([modelName isEqualToString:@"iPad2,4"]) {
modelName = @"iPad 2 (WiFi + Rev A)";
modelnumber = @"A1395";
}
else if([modelName isEqualToString:@"iPad3,1"]) {
modelName = @"iPad 3 (WiFi)";
modelnumber = @"A1416";
}
else if([modelName isEqualToString:@"iPad3,2"]) {
modelName = @"iPad 3 (GSM+CDMA)";
modelnumber = @"A1403";
}
else if([modelName isEqualToString:@"iPad3,3"]) {
modelName = @"iPad 3 (GSM)";
modelnumber = @"A1430";
}
else if([modelName isEqualToString:@"iPad3,4"]) {
modelName = @"iPad 4 (WiFi)";
modelnumber = @"A1458";
}
else if([modelName isEqualToString:@"iPad3,5"]) {
modelName = @"iPad 4 (GSM)";
modelnumber = @"A1459";
}
else if([modelName isEqualToString:@"iPad3,6"]) {
modelName = @"iPad 4 (GSM+CDMA)";
modelnumber = @"A1460";
}
//iPad mini
else if([modelName isEqualToString:@"iPad2,5"]) {
modelName = @"iPad mini (WiFi)";
modelnumber = @"A1432";
}
else if([modelName isEqualToString:@"iPad2,6"]) {
modelName = @"iPad mini (GSM)";
modelnumber = @"A1454";
}
else if([modelName isEqualToString:@"iPad2,7"]) {
modelName = @"iPad mini (GSM+CDMA)";
modelnumber = @"A1455";
}
//Apple TV, just for funn:)
else if([modelName isEqualToString:@"AppleTV2,1"]) {
modelName = @"Apple TV 2G";
modelnumber = @"A1378";
}
else if([modelName isEqualToString:@"AppleTV3,1"]) {
modelName = @"Apple TV 3G";
modelnumber = @"A1427";
}
else if([modelName isEqualToString:@"AppleTV3,2"]) {
modelName = @"Apple TV 3G (Rev A)";
modelnumber = @"A1469";
}
NSLog(@"Device model: %@/ %@",modelName,modelnumber);
This could be the output: Device model: iPhone 4 GSM/ iPhone3,1