如何通过代码查找iPhone/iPod设备型号(3G,3GS,4,4S)?

Gop*_*ath 7 iphone model ipod-touch

可能重复:
使用iPhone SDK确定设备(iPhone,iPod Touch)

我试图获得当前的设备型号名称,如3G,3GS,4,4S,iPodTouch(不同世代).但是,到目前为止我无法得到确切的结果.你能帮我找一下设备型号吗?在这里,我附上了我用来获取设备模型的代码.

UIDevice *device = [UIDevice currentDevice];
NSString *deviceVersion = [device systemVersion];//Return 4.0.1 and 5.0.1
NSString *deviceName = [device systemName];//Return iPhone, iPod Touch
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得3G,3GS,4,4S,iPod Touch,iPad等设备型号?提前致谢.

nit*_*hin 13

#import <sys/utsname.h>

NSString*
machineName()
{
    struct utsname systemInfo;
    uname(&systemInfo);

    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
}
Run Code Online (Sandbox Code Playgroud)

结果应该是:

@"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
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S
Run Code Online (Sandbox Code Playgroud)