识别iPad / iPhone / iPod型号xcode设备 - >已知名称

时间:2014-04-03 20:10:12

标签: ios iphone objective-c xcode ipad

我环顾四周,找不到所有可能的型号,通常高达iPad 3代和iPhone 5.什么是iPhone 5s,c和iPad的空气设备名称?

1 个答案:

答案 0 :(得分:1)

所以我花了一些时间研究并把它们放在一起。对于所有想要识别所有苹果触摸设备型号的开发人员,这里有一个列表,其中包括iPhone 5s,c,iPod touch 5 Gen iPad Air和iPad mini(最新型号):

#import "sys/sysctl.h"

        size_t size;
        sysctlbyname("hw.machine", NULL, &size, NULL, 0);
        char *machine = malloc(size);
        sysctlbyname("hw.machine", machine, &size, NULL, 0);
        NSString *platform = [NSString stringWithUTF8String:machine];
        free(machine);    
        NSString *deviceModelDetailed;
        if ([platform isEqualToString:@"iPhone1,1"]){
            deviceModelDetailed = @"iPhone 1G";
        }
        if ([platform isEqualToString:@"iPhone1,2"]){
            deviceModelDetailed = @"iPhone 3G";
        }
        if ([platform isEqualToString:@"iPhone2,1"]){
            deviceModelDetailed = @"iPhone 3GS";
        }
        if ([platform isEqualToString:@"iPhone3,1"]){
            deviceModelDetailed = @"iPhone 4";
        }
        if ([platform isEqualToString:@"iPhone3,2"]){
            deviceModelDetailed = @"iPhone 4 (GSM Rev A)";
        }
        if ([platform isEqualToString:@"iPhone3,3"]){
            deviceModelDetailed = @"iPhone 4 (CDMA)";
        }
        if ([platform isEqualToString:@"iPhone4,1"]){
            deviceModelDetailed = @"iPhone 4S";
        }
        if ([platform isEqualToString:@"iPhone5,1"]){
            deviceModelDetailed = @"iPhone 5 (GSM)";
        }
        if ([platform isEqualToString:@"iPhone5,2"]){
            deviceModelDetailed = @"iPhone 5 (CDMA)";
        }
        if ([platform isEqualToString:@"iPhone5,3"]){
            deviceModelDetailed = @"iPhone 5c (GSM)";
        }
        if ([platform isEqualToString:@"iPhone5,4"]){
            deviceModelDetailed = @"iPhone 5c (CDMA)";
        }
        if ([platform isEqualToString:@"iPhone6,1"]){
            deviceModelDetailed = @"iPhone 5s (GSM)";
        }
        if ([platform isEqualToString:@"iPhone6,2"]){
            deviceModelDetailed = @"iPhone 5s (CDMA)";
        }
        if ([platform isEqualToString:@"iPod1,1"]){
            deviceModelDetailed = @"iPod Touch 1G";
        }
        if ([platform isEqualToString:@"iPod2,1"]){
            deviceModelDetailed = @"iPod Touch 2G";
        }
        if ([platform isEqualToString:@"iPod3,1"]){
            deviceModelDetailed = @"iPod Touch 3G";
        }
        if ([platform isEqualToString:@"iPod4,1"]){
           deviceModelDetailed = @"iPod Touch 4G";
        }
        if ([platform isEqualToString:@"iPod5,1"]){
            deviceModelDetailed = @"iPod Touch 5G";
        }
        if ([platform isEqualToString:@"iPad1,1"]){
            deviceModelDetailed = @"iPad 1";
        }
        if ([platform isEqualToString:@"iPad2,1"]){
            deviceModelDetailed = @"iPad 2 (WiFi)";
        }
        if ([platform isEqualToString:@"iPad2,2"]){
            deviceModelDetailed = @"iPad 2 Wi-Fi + 3G (GSM)";
        }
        if ([platform isEqualToString:@"iPad2,3"]){
            deviceModelDetailed = @"iPad 2 Wi-Fi + 3G (CDMA)";
        }
        if ([platform isEqualToString:@"iPad2,3"]){
            deviceModelDetailed = @"iPad 2 Wi-Fi (Rev A)";
        }
        if ([platform isEqualToString:@"iPad2,5"]){
            deviceModelDetailed = @"iPad mini";
        }
        if ([platform isEqualToString:@"iPad2,6"]){
            deviceModelDetailed = @"iPad mini Wi-Fi + Cellular";
        }
        if ([platform isEqualToString:@"iPad2,7"]){
            deviceModelDetailed = @"iPad mini Wi-Fi + Cellular (MM)";
        }
        if ([platform isEqualToString:@"iPad3,1"]){
            deviceModelDetailed = @"iPad 3 (WiFi)";
        }
        if ([platform isEqualToString:@"iPad3,2"]){
            deviceModelDetailed = @"iPad 3 (GSM)";
        }
        if ([platform isEqualToString:@"iPad3,3"]){
            deviceModelDetailed = @"iPad 3 (CDMA)";
        }
        if ([platform isEqualToString:@"iPad3,4"]){
            deviceModelDetailed = @"iPad (4th generation)";
        }
        if ([platform isEqualToString:@"iPad3,5"]){
            deviceModelDetailed = @"iPad (4th generation) Wi-Fi + Cellular";
        }
        if ([platform isEqualToString:@"iPad3,6"]){
            deviceModelDetailed = @"iPad (4th generation) Wi-Fi + Cellular (MM)";
        }
        if ([platform isEqualToString:@"iPad4,1"]){
            deviceModelDetailed = @"iPad Air";
        }
        if ([platform isEqualToString:@"iPad4,2"]){
            deviceModelDetailed = @"iPad Air Wi-Fi + Cellular";
        }
        if ([platform isEqualToString:@"iPad4,4"]){
            deviceModelDetailed = @"iPad mini with Retina display";
        }
        if ([platform isEqualToString:@"iPad4,5"]){
            deviceModelDetailed = @"iPad mini with Retina display Wi-Fi + Cellular";
        }