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

可能重复:
用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

我如何获得设备型号3G,3GS,4,4S,iPod Touch,iPad? 提前致谢。


#import <sys/utsname.h>

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

    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
}

结果应该是:

@"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

girhub上有一个图书馆可以做到这一点。 看到这个链接:

https://github.com/erica/uidevice-extension

链接地址: http://www.djcxy.com/p/8891.html

上一篇: How to find iPhone/iPod Device model(3G,3GS,4,4S) by code?

下一篇: iPod Touch Second Generation