- (NSString*) deviceName
{
struct utsname systemInfo;
uname(&systemInfo);
NSString* code = [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
static NSDictionary* deviceNamesByCode = nil;
if (!deviceNamesByCode) {
deviceNamesByCode = @{@"i386" :@"Simulator",
@"iPod1,1" :@"iPodTouch1", // (Original)
@"iPod2,1" :@"iPodTouch2", // (Second Generation)
@"iPod3,1" :@"iPodTouch3", // (Third Generation)
@"iPod4,1" :@"iPodTouch4", // (Fourth Generation)
@"iPhone1,1" :@"iPhone2G11", // (Original)
@"iPhone1,2" :@"iPhone3G12", // (3G)
@"iPhone2,1" :@"iPhone3GS21", // (3GS)
@"iPad1,1" :@"iPad", // (Original)
@"iPad2,1" :@"iPad2", //
@"iPad3,1" :@"iPad", // (3rd Generation)
@"iPhone3,1" :@"iPhone431",//
@"iPhone3,2" :@"iPhone432",
@"iPhone3,3" :@"iPhone433",
@"iPhone4,1" :@"iPhone4S41",//
@"iPhone4,2" :@"iPhone442",
@"iPhone4,3" :@"iPhone443",
@"iPhone5,1" :@"iPhone551", // (model A1428, AT&T/Canada)
@"iPhone5,2" :@"iPhone552",
@"iPad3,4" :@"iPad", // (4th Generation)
@"iPad2,5" :@"iPadMini", // (Original)
@"iPhone5,3" :@"iPhone5C53", // (model A1456, A1532 | GSM)
@"iPhone5,4" :@"iPhone5C54", // (model A1507, A1516, A1526 (China), A1529 | Global)
@"iPhone6,1" :@"iPhone5S61", // (model A1433, A1533 | GSM)
@"iPhone6,2" :@"iPhone5S62", // (model A1457, A1518, A1528 (China), A1530 | Global)
@"iPad4,1" :@"iPadAir", // 5th Generation iPad (iPad Air) - Wifi
@"iPad4,2" :@"iPadAir", // 5th Generation iPad (iPad Air) - Cellular
@"iPad4,4" :@"iPadMini", // (2nd Generation iPad Mini - Wifi)
@"iPad4,5" :@"iPadMini" // (2nd Generation iPad Mini - Cellular)
};
}
小伙伴们快去试试吧!~