ios史上最全的获取手机型号方法

  • (NSString*)deviceModel
    {
    // 需要#import "sys/utsname.h"
    struct utsname systemInfo;
    uname(&systemInfo);
    NSString * platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

    // iPhone
    if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone2G";
    if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone3G";
    if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone3GS";
    if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone4";
    if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone4";
    if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone4";
    if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone4S";
    if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone5";
    if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone5";
    if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone5c";
    if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone5c";
    if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone5s";
    if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone5s";
    if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone6";
    if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone6Plus";
    if ([platform isEqualToString:@"iPhone8,1"]) return @"iPhone6s";
    if ([platform isEqualToString:@"iPhone8,2"]) return @"iPhone6sPlus";
    if ([platform isEqualToString:@"iPhone8,3"]) return @"iPhoneSE";
    if ([platform isEqualToString:@"iPhone8,4"]) return @"iPhoneSE";
    if ([platform isEqualToString:@"iPhone9,1"]) return @"iPhone7";
    if ([platform isEqualToString:@"iPhone9,2"]) return @"iPhone7Plus";
    if ([platform isEqualToString:@"iPhone9,3"]) return @"iPhone7";
    if ([platform isEqualToString:@"iPhone9,4"]) return @"iPhone7Plus";
    if ([platform isEqualToString:@"iPhone10,1"]) return @"iPhone 8";
    if ([platform isEqualToString:@"iPhone10,4"]) return @"iPhone 8";
    if ([platform isEqualToString:@"iPhone10,2"]) return @"iPhone 8 Plus";
    if ([platform isEqualToString:@"iPhone10,5"]) return @"iPhone 8 Plus";
    if ([platform isEqualToString:@"iPhone10,3"]) return @"iPhone X";
    if ([platform isEqualToString:@"iPhone10,6"]) return @"iPhone X";

    //iPod Touch
    if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch";
    if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch2G";
    if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch3G";
    if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch4G";
    if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch5G";
    if ([platform isEqualToString:@"iPod7,1"]) return @"iPod Touch6G";

    //iPad
    if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
    if ([platform isEqualToString:@"iPad2,1"]) return @"iPad2";
    if ([platform isEqualToString:@"iPad2,2"]) return @"iPad2";
    if ([platform isEqualToString:@"iPad2,3"]) return @"iPad2";
    if ([platform isEqualToString:@"iPad2,4"]) return @"iPad2";
    if ([platform isEqualToString:@"iPad3,1"]) return @"iPad3";
    if ([platform isEqualToString:@"iPad3,2"]) return @"iPad3";
    if ([platform isEqualToString:@"iPad3,3"]) return @"iPad3";
    if ([platform isEqualToString:@"iPad3,4"]) return @"iPad4";
    if ([platform isEqualToString:@"iPad3,5"]) return @"iPad4";
    if ([platform isEqualToString:@"iPad3,6"]) return @"iPad4";
    if ([platform isEqualToString:@"iPad6,11"]) return @"iPad(9.7)";
    if ([platform isEqualToString:@"iPad6,12"]) return @"iPad(9.7)";

    //iPad Air
    if ([platform isEqualToString:@"iPad4,1"]) return @"iPadAir";
    if ([platform isEqualToString:@"iPad4,2"]) return @"iPadAir";
    if ([platform isEqualToString:@"iPad4,3"]) return @"iPadAir";
    if ([platform isEqualToString:@"iPad5,3"]) return @"iPadAir2";
    if ([platform isEqualToString:@"iPad5,4"]) return @"iPadAir2";

    //iPad mini
    if ([platform isEqualToString:@"iPad2,5"]) return @"iPad mini1G";
    if ([platform isEqualToString:@"iPad2,6"]) return @"iPad mini1G";
    if ([platform isEqualToString:@"iPad2,7"]) return @"iPad mini1G";
    if ([platform isEqualToString:@"iPad4,4"]) return @"iPad mini2";
    if ([platform isEqualToString:@"iPad4,5"]) return @"iPad mini2";
    if ([platform isEqualToString:@"iPad4,6"]) return @"iPad mini2";
    if ([platform isEqualToString:@"iPad4,7"]) return @"iPad mini3";
    if ([platform isEqualToString:@"iPad4,8"]) return @"iPad mini3";
    if ([platform isEqualToString:@"iPad4,9"]) return @"iPad mini3";
    if ([platform isEqualToString:@"iPad5,1"]) return @"iPad mini4";
    if ([platform isEqualToString:@"iPad5,2"]) return @"iPad mini4";

    //iPad Pro
    if ([platform isEqualToString:@"iPad6,3"]) return @"iPad Pro(9.7)";
    if ([platform isEqualToString:@"iPad6,4"]) return @"iPad Pro(9.7)";
    if ([platform isEqualToString:@"iPad6,7"]) return @"iPad Pro(12.9)";
    if ([platform isEqualToString:@"iPad6,8"]) return @"iPad Pro(12.9)";
    if ([platform isEqualToString:@"iPad7,1"]) return @"iPad Pro2(12.9)";
    if ([platform isEqualToString:@"iPad7,2"]) return @"iPad Pro2(12.9)";
    if ([platform isEqualToString:@"iPad7,3"]) return @"iPad Pro2(10.5)";
    if ([platform isEqualToString:@"iPad7,4"]) return @"iPad Pro2(10.5)";

    if ([platform isEqualToString:@"i386"]) return @"iPhoneSimulator";
    if ([platform isEqualToString:@"x86_64"]) return @"iPhoneSimulator";

    return platform;
    }

你可能感兴趣的:(ios史上最全的获取手机型号方法)