1. [UIDevice currentDevice].model 自己写的看只抓到模拟器和iPhone。暂时不推荐。
2.自己写的找的方法再添加。直接 NSString * deviceModle= [selfdoDevicePlatform];
即可获得?设备型号
?- (NSString*) doDevicePlatform
{
size_t size;
int nR = sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = (char *)malloc(size);
nR = sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSStringstringWithCString:machineencoding:NSUTF8StringEncoding];
free(machine);
if ([platform isEqualToString:@"iPhone1,1"]) {
platform = @"iPhone";
} elseif ([platform isEqualToString:@"iPhone1,2"]) {
platform = @"iPhone 3G";
} elseif ([platform isEqualToString:@"iPhone2,1"]) {
platform = @"iPhone 3GS";
} elseif ([platform isEqualToString:@"iPhone3,1"]||[platformisEqualToString:@"iPhone3,2"]||[platform isEqualToString:@"iPhone3,3"]) {
platform = @"iPhone 4";
} elseif ([platform isEqualToString:@"iPhone4,1"]) {
platform = @"iPhone 4S";
} elseif ([platform isEqualToString:@"iPhone5,1"]||[platformisEqualToString:@"iPhone5,2"]) {
platform = @"iPhone 5";
}elseif ([platform isEqualToString:@"iPhone5,3"]||[platformisEqualToString:@"iPhone5,4"]) {
platform = @"iPhone 5C";
}elseif ([platform isEqualToString:@"iPhone6,2"]||[platformisEqualToString:@"iPhone6,1"]) {
platform = @"iPhone 5S";
}elseif ([platform isEqualToString:@"iPod4,1"]) {
platform = @"iPod touch 4";
}elseif ([platform isEqualToString:@"iPod5,1"]) {
platform = @"iPod touch 5";
}elseif ([platform isEqualToString:@"iPod3,1"]) {
platform = @"iPod touch 3";
}elseif ([platform isEqualToString:@"iPod2,1"]) {
platform = @"iPod touch 2";
}elseif ([platform isEqualToString:@"iPod1,1"]) {
platform = @"iPod touch";
} elseif ([platform isEqualToString:@"iPad3,2"]||[platformisEqualToString:@"iPad3,1"]) {
platform = @"iPad 3";
} elseif ([platform isEqualToString:@"iPad2,2"]||[platformisEqualToString:@"iPad2,1"]||[platform isEqualToString:@"iPad2,3"]||[platformisEqualToString:@"iPad2,4"]) {
platform = @"iPad 2";
}elseif ([platform isEqualToString:@"iPad1,1"]) {
platform = @"iPad 1";
}elseif ([platform isEqualToString:@"iPad2,5"]||[platformisEqualToString:@"iPad2,6"]||[platform isEqualToString:@"iPad2,7"]) {
platform = @"ipad mini";
} elseif ([platform isEqualToString:@"iPad3,3"]||[platformisEqualToString:@"iPad3,4"]||[platform isEqualToString:@"iPad3,5"]||[platformisEqualToString:@"iPad3,6"]) {
platform = @"ipad 3";
}elseif([platform isEqualToString:@"iPhone7,2"]){
platform = @"iPhone6";
}elseif([platform isEqualToString:@"iPhone7,1"]){
platform = @"iPhone6+";
}
return platform;
}