The code is as follows:
+ (nsstring*) devicestring
{
Need #import "Sys/utsname.h"
struct Utsname systemInfo;
Uname (&systeminfo);
NSString *devicestring = [NSString stringWithCString:systemInfo.machine encoding:nsutf8stringencoding];
if ([devicestring isequaltostring:@ "iphone1,1"]) return @ "IPhone 1G";
if ([devicestring isequaltostring:@ "iphone1,2"]) return @ "IPhone 3G";
if ([devicestring isequaltostring:@ "iphone2,1"]) return @ "IPhone 3GS";
if ([devicestring isequaltostring:@ "iphone3,1"]) return @ "IPhone 4";
if ([devicestring isequaltostring:@ "iphone3,2"]) return @ "Verizon IPhone 4";
if ([devicestring isequaltostring:@ "iphone4,1"]) return @ "IPhone 4S";
if ([devicestring isequaltostring:@ "iphone5,2"]) return @ "IPhone 5";
if ([devicestring isequaltostring:@ "iphone5,3"]) return @ "IPhone 5C";
if ([devicestring isequaltostring:@ "iphone5,4"]) return @ "IPhone 5C";
if ([devicestring isequaltostring:@ "iphone6,2"]) return @ "IPhone 5S";
if ([devicestring isequaltostring:@ "ipod1,1"]) return @ "IPod Touch 1G";
if ([devicestring isequaltostring:@ "ipod2,1"]) return @ "IPod Touch 2G";
if ([devicestring isequaltostring:@ "ipod3,1"]) return @ "IPod Touch 3G";
if ([devicestring isequaltostring:@ "ipod4,1"]) return @ "IPod Touch 4G";
if ([devicestring isequaltostring:@ "ipad1,1"]) return @ "IPad";
if ([devicestring isequaltostring:@ "ipad2,1"]) return @ "IPad 2 (WiFi)";
if ([devicestring isequaltostring:@ "ipad2,2"]) return @ "IPad 2 (GSM)";
if ([devicestring isequaltostring:@ "ipad2,3"]) return @ "IPad 2 (CDMA)";
if ([devicestring isequaltostring:@ "ipad2,5"]) return @ "IPad Mini";
if ([devicestring isequaltostring:@ "i386"]) return @ "Simulator";
if ([devicestring isequaltostring:@ "x86_64"]) return @ "Simulator";
NSLog (@ "Note:unknown device type:%@", devicestring);
return devicestring;
}
iOS determines the current device type