#import <sys/utsname.h> // import it in your header or implementation file.
NSString* deviceName()
{
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
}Copy the code
Results obtained:
//Simultor
@"i386" on 32-bit Simulator
@"x86_64" on 64-bit Simulator
//iPhone
@"IPhone1, 1" on iPhone
@"IPhone1, 2" on iPhone 3G
@IPhone2, 1 "" on iPhone 3GS
@"However, 1" on iPhone 4 (GSM)
@"However, 3" on iPhone 4 (CDMA/Verizon/Sprint)
@"The iphone 4, 1" on iPhone 4S
@"The iphone 5, 1" on iPhone 5 (model A1428, AT&T/Canada)
@"The iphone 5, 2" on iPhone 5 (model A1429, everything else)
@"The iphone 5, 3" on iPhone 5c (model A1456, A1532 | GSM)
@"The iphone 5, 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)
@"IPhone7, 1" on iPhone 6 Plus
@"IPhone7, 2" on iPhone 6
@"IPhone8, 1" on iPhone 6S
@"IPhone8, 2" on iPhone 6S Plus
@"IPhone8, 4" on iPhone SE
@"IPhone9, 1" on iPhone 7 (CDMA)
@"IPhone9, 3" on iPhone 7 (GSM)
@"IPhone9, 2" on iPhone 7 Plus (CDMA)
@"IPhone9, 4" on iPhone 7 Plus (GSM)
@"IPhone10, 1" on iPhone 8 (CDMA)
@"IPhone10, 4" on iPhone 8 (GSM)
@"IPhone10, 2" on iPhone 8 Plus (CDMA)
@"IPhone10, 5" on iPhone 8 Plus (GSM)
@"IPhone10, 3" on iPhone X (CDMA)
@"IPhone10, 6" on iPhone X (GSM)
@"IPhone12, 1" on iPhone 11
@"IPhone11, 8" on iPhone XR
@"IPhone11, 2" on iPhone xs
//iPad 1
@"IPad1, 1" on iPad - Wifi (model A1219)
@"IPad1, 1" on iPad - Wifi + Cellular (model A1337)
//iPad 2
@"And 1" - Wifi (model A1395)
@"And 2" - GSM (model A1396)
@"And 3" - 3G (model A1397)
@"And 4" - Wifi (model A1395)
// iPad Mini
@"And 5" - Wifi (model A1432)
@"And 6" - Wifi + Cellular (model A1454)
@"And 7" - Wifi + Cellular (model A1455)
//iPad 3
@"IPad3, 1" - Wifi (model A1416)
@"IPad3, 2" - Wifi + Cellular (model A1403)
@"IPad3, 3" - Wifi + Cellular (model A1430)
//iPad 4
@"IPad3, 4" - Wifi (model A1458)
@"Ipad 3, 5" - Wifi + Cellular (model A1459)
@"IPad3, 6" - Wifi + Cellular (model A1460)
//iPad AIR
@"IPad4, 1" - Wifi (model A1474)
@"IPad4, 2" - Wifi + Cellular (model A1475)
@"IPad4, 3" - Wifi + Cellular (model A1476)
// iPad Mini 2
@"IPad4, 4" - Wifi (model A1489)
@"IPad4, 5" - Wifi + Cellular (model A1490)
@"IPad4, 6" - Wifi + Cellular (model A1491)
// iPad Mini 3
@"IPad4, 7" - Wifi (model A1599)
@"IPad4, 8" - Wifi + Cellular (model A1600)
@"IPad4, 9" - Wifi + Cellular (model A1601)
// iPad Mini 4
@"Lofty, 1" - Wifi (model A1538)
@"The lofty, 2" - Wifi + Cellular (model A1550)
//iPad AIR 2
@"The lofty, 3" - Wifi (model A1566)
@"Lofty, 4" - Wifi + Cellular (model A1567)
// iPad PRO 12.9"@"IPad6, 3" - Wifi (model A1673)
@"IPad6, 4" - Wifi + Cellular (model A1674)
@"IPad6, 4"- Wifi + Cellular (Model A1675) //iPad PRO 9.7"
@"IPad6, 7" - Wifi (model A1584)
@"IPad6, 8" - Wifi + Cellular (model A1652)
//iPad (5th generation)
@"IPad6, 11" - Wifi (model A1822)
@"IPad6, 12" - Wifi + Cellular (model A1823)
//iPad PRO 12.9" (2nd Gen)
@"IPad7, 1" - Wifi (model A1670)
@"IPad7, 2" - Wifi + Cellular (model A1671)
@"IPad7, 2"- Wifi + Cellular (Model A1821) //iPad PRO 10.5"
@"IPad7, 3" - Wifi (model A1701)
@"IPad7, 4" - Wifi + Cellular (model A1709)
//iPod Touch
@"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
@"IPod7, 1" on iPod Touch 6th GenerationCopy the code