首页 » IOS » 获取iOS设备型号大全

获取iOS设备型号大全

原文 http://blog.csdn.net/laodeng0512/article/details/75018905

2017-07-12 17:20:19阅读(436)

获取iOS设备型号,找了一圈发现一般写的都不够全,自己完善了一下。

调用记得加上头文件:

#import <sys/utsname.h>


+ (NSString*)deviceString

{

    struct utsname systemInfo;

    uname(&systemInfo);

    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

    

    if ([deviceString isEqualToString:@"iPhone1,1"])    return [NSString stringWithFormat:@"%@",@"iPhone1G"];

    if ([deviceString isEqualToString:@"iPhone1,2"])    return [NSString stringWithFormat:@"%@",@"iPhone3G"];

    if ([deviceString isEqualToString:@"iPhone2,1"])    return [NSString stringWithFormat:@"%@",@"iPhone3GS"];

    if ([deviceString isEqualToString:@"iPhone3,1"])    return [NSString stringWithFormat:@"%@",@"iPhone4"];

    if ([deviceString isEqualToString:@"iPhone4,1"])    return [NSString stringWithFormat:@"%@",@"iPhone4S"];

    if ([deviceString isEqualToString:@"iPhone5,1"])    return [NSString stringWithFormat:@"%@",@"iPhone5"];

    if ([deviceString isEqualToString:@"iPhone5,2"])    return [NSString stringWithFormat:@"%@",@"iPhone5"];

    if ([deviceString isEqualToString:@"iPhone5,3"])    return [NSString stringWithFormat:@"%@",@"iPhone5c"];

    if ([deviceString isEqualToString:@"iPhone5,4"])    return [NSString stringWithFormat:@"%@",@"iPhone5c"];

    if ([deviceString isEqualToString:@"iPhone6,1"])    return [NSString stringWithFormat:@"%@",@"iPhone5s"];

    if ([deviceString isEqualToString:@"iPhone6,2"])    return [NSString stringWithFormat:@"%@",@"iPhone5s"];

    if ([deviceString isEqualToString:@"iPhone7,1"])    return [NSString stringWithFormat:@"%@",@"iPhone6Plus"];

    if ([deviceString isEqualToString:@"iPhone7,2"])    return [NSString stringWithFormat:@"%@",@"iPhone6"];

    if ([deviceString isEqualToString:@"iPhone8,4"])    return [NSString stringWithFormat:@"%@",@"iPhone SE"];

    if ([deviceString isEqualToString:@"iPhone8,3"])    return [NSString stringWithFormat:@"%@",@"iPhone SE"];

    if ([deviceString isEqualToString:@"iPhone8,2"])    return [NSString stringWithFormat:@"%@",@"iPhone6sPlus"];

    if ([deviceString isEqualToString:@"iPhone8,1"])    return [NSString stringWithFormat:@"%@",@"iPhone6s"];

    if ([deviceString isEqualToString:@"iPhone9,2"])    return [NSString stringWithFormat:@"%@",@"iPhone7Plus"];

    if ([deviceString isEqualToString:@"iPhone9,1"])    return [NSString stringWithFormat:@"%@",@"iPhone7"];

    if ([deviceString isEqualToString:@"iPhone9,4"])    return [NSString stringWithFormat:@"%@",@"iPhone7Plus"];

    if ([deviceString isEqualToString:@"iPhone9,3"])    return [NSString stringWithFormat:@"%@",@"iPhone7"];

    if ([deviceString isEqualToString:@"iPhone3,2"])    return [NSString stringWithFormat:@"%@",@"iPhone4"];

    if ([deviceString isEqualToString:@"iPod1,1"])      return [NSString stringWithFormat:@"%@",@"iPodTouch1G"];

    if ([deviceString isEqualToString:@"iPod2,1"])      return [NSString stringWithFormat:@"%@",@"iPodTouch2G"];

    if ([deviceString isEqualToString:@"iPod3,1"])      return [NSString stringWithFormat:@"%@",@"iPodTouch3G"];

    if ([deviceString isEqualToString:@"iPod4,1"])      return [NSString stringWithFormat:@"%@",@"iPodTouch4G"];

    if ([deviceString isEqualToString:@"iPad1,1"])      return [NSString stringWithFormat:@"%@",@"iPad"];

    if ([deviceString isEqualToString:@"iPad2,1"])      return [NSString stringWithFormat:@"%@",@"iPad2"];

    if ([deviceString isEqualToString:@"iPad2,2"])      return [NSString stringWithFormat:@"%@",@"iPad2"];

    if ([deviceString isEqualToString:@"iPad2,3"])      return [NSString stringWithFormat:@"%@",@"iPad2"];

    

    if ([deviceString isEqualToString:@"iPad2,4"])      return [NSString stringWithFormat:@"%@",@"iPad 2"];

    if ([deviceString isEqualToString:@"iPad2,5"])      return [NSString stringWithFormat:@"%@",@"iPad Mini (WiFi)"];

    if ([deviceString isEqualToString:@"iPad2,6"])      return [NSString stringWithFormat:@"%@",@"iPad Mini"];

    if ([deviceString isEqualToString:@"iPad2,7"])      return [NSString stringWithFormat:@"%@",@"iPad Mini (GSM+CDMA)"];

    if ([deviceString isEqualToString:@"iPad3,1"])      return [NSString stringWithFormat:@"%@",@"iPad 3 (WiFi)"];

    if ([deviceString isEqualToString:@"iPad3,2"])      return [NSString stringWithFormat:@"%@",@"iPad 3 (GSM+CDMA)"];

    if ([deviceString isEqualToString:@"iPad3,3"])      return [NSString stringWithFormat:@"%@",@"iPad 3"];

    if ([deviceString isEqualToString:@"iPad3,4"])      return [NSString stringWithFormat:@"%@",@"iPad 4 (WiFi)"];

    if ([deviceString isEqualToString:@"iPad3,5"])      return [NSString stringWithFormat:@"%@",@"iPad 4"];

    if ([deviceString isEqualToString:@"iPad3,6"])      return [NSString stringWithFormat:@"%@",@"iPad 4 (GSM+CDMA)"];

    if ([deviceString isEqualToString:@"iPad4,1"])      return [NSString stringWithFormat:@"%@",@"iPad Air (WiFi)"];

    if ([deviceString isEqualToString:@"iPad4,2"])      return [NSString stringWithFormat:@"%@",@"iPad Air (Cellular)"];

    if ([deviceString isEqualToString:@"iPad4,4"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 2 (WiFi)"];

    if ([deviceString isEqualToString:@"iPad4,5"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 2 (Cellular)"];

    if ([deviceString isEqualToString:@"iPad4,6"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 2"];

    if ([deviceString isEqualToString:@"iPad4,7"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 3"];

    if ([deviceString isEqualToString:@"iPad4,8"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 3"];

    if ([deviceString isEqualToString:@"iPad4,9"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 3"];

    if ([deviceString isEqualToString:@"iPad5,1"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 4 (WiFi)"];

    if ([deviceString isEqualToString:@"iPad5,2"])      return [NSString stringWithFormat:@"%@",@"iPad Mini 4 (LTE)"];

    if ([deviceString isEqualToString:@"iPad5,3"])      return [NSString stringWithFormat:@"%@",@"iPad Air 2"];

    if ([deviceString isEqualToString:@"iPad5,4"])      return [NSString stringWithFormat:@"%@",@"iPad Air 2"];

    if ([deviceString isEqualToString:@"iPad6,3"])      return [NSString stringWithFormat:@"%@",@"iPad Pro 9.7"];

    if ([deviceString isEqualToString:@"iPad6,4"])      return [NSString stringWithFormat:@"%@",@"iPad Pro 9.7"];

    if ([deviceString isEqualToString:@"iPad6,7"])      return [NSString stringWithFormat:@"%@",@"iPad Pro 12.9"];

    if ([deviceString isEqualToString:@"iPad6,8"])      return [NSString stringWithFormat:@"%@",@"iPad Pro 12.9"];

    

    if ([deviceString isEqualToString:@"i386"])         return [NSString stringWithFormat:@"%@",@"Simulator"];

    if ([deviceString isEqualToString:@"x86_64"])       return [NSString stringWithFormat:@"%@",@"Simulator"];

    

    return [NSString stringWithFormat:@"%@",deviceString];

}




最新发布

CentOS专题

关于本站

5ibc.net旗下博客站精品博文小部分原创、大部分从互联网收集整理。尊重作者版权、传播精品博文,让更多编程爱好者知晓!

小提示

按 Ctrl+D 键,
把本文加入收藏夹