获取IOS硬件设备的型号
1 /* 2 * 获取版本型号 3 * "i386" simulator 4 * "iPod1,1" iPod Touch 5 * "iPhone1,1" iPhone 6 * "iPhone1,2" iPhone 3G 7 * "iPhone2,1" iPhone 3GS 8 * "iPad1,1" iPad 9 * "iPhone3,1" iPhone 4 10 */ 11 +(NSString *)deviceString; 12 13 14 15 16 +(NSString*)deviceString 17 { 18 struct utsname systemInfo; 19 uname(&systemInfo); 20 NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; 21 22 if ([deviceString isEqualToString:@"iPhone1,1"]) return @"iPhone 1G"; 23 if ([deviceString isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; 24 if ([deviceString isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS"; 25 if ([deviceString isEqualToString:@"iPhone3,1"]) return @"iPhone 4"; 26 if ([deviceString isEqualToString:@"iPhone3,2"]) return @"Verizon iPhone 4"; 27 if ([deviceString isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G"; 28 if ([deviceString isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G"; 29 if ([deviceString isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G"; 30 if ([deviceString isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G"; 31 if ([deviceString isEqualToString:@"iPad1,1"]) return @"iPad"; 32 if ([deviceString isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)"; 33 if ([deviceString isEqualToString:@"iPad2,2"]) return @"iPad 2 (GSM)"; 34 if ([deviceString isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)"; 35 if ([deviceString isEqualToString:@"i386"]) return @"Simulator"; 36 if ([deviceString isEqualToString:@"x86_64"]) return @"Simulator"; 37 38 DLog(@"NOTE: Unknown device type: %@", deviceString); 39 return deviceString; 40 }
花开花谢春不管,水暖水寒鱼自知.