本文共 1949 字,大约阅读时间需要 6 分钟。
方法1:
#include <sys/sysctl.h>
- (NSString *) platform
{ size_t size; sysctlbyname("hw.machine",NULL, &size, NULL,0); char *machine = malloc(size); sysctlbyname("hw.machine", machine, &size,NULL, 0); NSString*platform = [NSStringstringWithCString:machineencoding:NSUTF8StringEncoding]; free(machine); return platform; }方法2:
#import <sys/utsname.h>
NSString*machineName()
{
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}
逗号后面数字解释:(i386是指模拟器) 1-WiFi版 2-GSM/WCDMA 3G版 3-CDMA版仅供参考:
AppleTV(2G) (AppleTV2,1)
iPad (iPad1,1) iPad2,1 (iPad2,1)Wifi版 iPad2,2 (iPad2,2)GSM3G版 iPad2,3 (iPad2,3)CDMA3G版 iPhone (iPhone1,1) iPhone3G (iPhone1,2) iPhone3GS (iPhone2,1) iPhone4 (iPhone3,1) iPhone4(vz) (iPhone3,3)iPhone4 CDMA版 iPhone4S (iPhone4,1) iPodTouch(1G) (iPod1,1) iPodTouch(2G) (iPod2,1) iPodTouch(3G) (iPod3,1)iPodTouch(4G) (iPod4,1)
仅供参考:
@"i386" on the simulator
@"iPod1,1" on iPod Touch
@"iPod2,1" on iPod Touch Second Generation
@"iPod3,1" on iPod Touch Third Generation
@"iPod4,1" on iPod Touch Fourth Generation
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1" on iPad
@"iPad2,1" on iPad 2
@"iPad3,1" on 3rd Generation iPad
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S
@"iPhone5,1" on iPhone 5 (model A1428, AT&T/Canada)
@"iPhone5,2" on iPhone 5 (model A1429, everything else)
@"iPad3,4" on 4th Generation iPad@"iPad2,5" on iPad Mini
@"iPhone5,3" on iPhone 5c (model A1456, A1532 | GSM)
@"iPhone5,4" on iPhone 5c (model A1507, A1516, A1526 (China), A1529 | Global)
@"iPhone6,1" on iPhone 5s (model A1433, A1533 | GSM)
@"iPhone6,2" on iPhone 5s (model A1457, A1518, A1528 (China), A1530 | Global)
@"iPad4,1" on 5th Generation iPad (iPad Air) - Wifi
@"iPad4,2" on 5th Generation iPad (iPad Air) - Cellular
@"iPad4,4" on 2nd Generation iPad Mini - Wifi
@"iPad4,5" on 2nd Generation iPad Mini - Cellular
PS:
附上IOS不同设备的参数URL
转载地址:http://ywzli.baihongyu.com/