iOS 获取最新设备型号方法

1.IOS 获取最新设备型号方法

列表最新对照表:http://theiphonewiki.com/wiki/Models

方法:

#import "sys/utsname.h"
struct utsname systemInfo;
  uname(&systemInfo);
  NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];  

这样得到的 deviceString 是iPhone5,2 的设备号,根据对照表可以获取到当前手机型号。

完整函数:

struct utsname systemInfo;
    uname(&systemInfo);
    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];  

    NSArray *modelArray = @[  

                            @"i386", @"x86_64",  

                            @"iPhone1,1",
                            @"iPhone1,2",
                            @"iPhone2,1",
                            @"iPhone3,1",
                            @"iPhone3,2",
                            @"iPhone3,3",
                            @"iPhone4,1",
                            @"iPhone5,1",
                            @"iPhone5,2",
                            @"iPhone5,3",
                            @"iPhone5,4",
                            @"iPhone6,1",
                            @"iPhone6,2",  

                            @"iPod1,1",
                            @"iPod2,1",
                            @"iPod3,1",
                            @"iPod4,1",
                            @"iPod5,1",  

                            @"iPad1,1",
                            @"iPad2,1",
                            @"iPad2,2",
                            @"iPad2,3",
                            @"iPad2,4",
                            @"iPad3,1",
                            @"iPad3,2",
                            @"iPad3,3",
                            @"iPad3,4",
                            @"iPad3,5",
                            @"iPad3,6",  

                            @"iPad2,5",
                            @"iPad2,6",
                            @"iPad2,7",
                            ];
    NSArray *modelNameArray = @[  

                                @"iPhone Simulator", @"iPhone Simulator",  

                                @"iPhone 2G",
                                @"iPhone 3G",
                                @"iPhone 3GS",
                                @"iPhone 4(GSM)",
                                @"iPhone 4(GSM Rev A)",
                                @"iPhone 4(CDMA)",
                                @"iPhone 4S",
                                @"iPhone 5(GSM)",
                                @"iPhone 5(GSM+CDMA)",
                                @"iPhone 5c(GSM)",
                                @"iPhone 5c(Global)",
                                @"iphone 5s(GSM)",
                                @"iphone 5s(Global)",  

                                @"iPod Touch 1G",
                                @"iPod Touch 2G",
                                @"iPod Touch 3G",
                                @"iPod Touch 4G",
                                @"iPod Touch 5G",  

                                @"iPad",
                                @"iPad 2(WiFi)",
                                @"iPad 2(GSM)",
                                @"iPad 2(CDMA)",
                                @"iPad 2(WiFi + New Chip)",
                                @"iPad 3(WiFi)",
                                @"iPad 3(GSM+CDMA)",
                                @"iPad 3(GSM)",
                                @"iPad 4(WiFi)",
                                @"iPad 4(GSM)",
                                @"iPad 4(GSM+CDMA)",  

                                @"iPad mini (WiFi)",
                                @"iPad mini (GSM)",
                                @"ipad mini (GSM+CDMA)"
                                ];
    NSInteger modelIndex = - 1;
    NSString *modelNameString = nil;
    modelIndex = [modelArray indexOfObject:deviceString];
    if (modelIndex >= 0 && modelIndex < [modelNameArray count]) {
        modelNameString = [modelNameArray objectAtIndex:modelIndex];
    }  

    NSLog(@"----设备类型---%@",modelNameString); 

注:struct utsname systemInfo; 这是LINUX系统放硬件版本的信息的地方

附录:

?//    IOS-获取Model(设备型号)、Version(设备版本号)、app(程序版本号)等
    NSLog(@"name: %@", [[UIDevice currentDevice] name]);
    NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
    NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
    NSLog(@"model: %@", [[UIDevice currentDevice] model]);
    NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);  

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  

    CFShow((__bridge CFTypeRef)(infoDictionary));  

    // app名称
    NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
    // app版本
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    // app build版本
    NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion”];  
时间: 2024-11-08 10:23:08

iOS 获取最新设备型号方法的相关文章

IOS获取手机设备型号

最新型号的设备列表https://www.theiphonewiki.com/wiki/Models 1 #import "iosutils/IOSUtils.h" 2 #import "sys/sysctl.h" 3 #import "sys/utsname.h" 4 5 @implementation IOSUtils 6 7 + (NSString *)getCurrentDeviceModel 8 { 9 struct utsname s

iOS获取当前设备方向

http://www.cnblogs.com/Yukang1989/p/3160980.html iOS获取当前设备方向 三种方式: self.interfaceOrientation [[UIApplication sharedApplication] statusBarOrientation] [[UIDevice currentDevice] orientation] 但是实际使用时有区别的: self.interfaceOrientation returns UIInterfaceOri

iOS 获取 当前设备 可用内存 及当前 应用 所占内存

// 获取当前设备可用内存及所占内存的头文件 #import <sys/sysctl.h> #import <mach/mach.h> // 获取当前设备可用内存(单位:MB) - (double)availableMemory { vm_statistics_data_t vmStats; mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT; kern_return_t kernReturn = host_statistic

[方法提炼] 获取Android设备序列号方法

通过这个方法可以检测设备是否连接成功,如果有一台或者多台设备,可以将所有设备序列号全部输出 1 # -*- coding:utf-8 -*- 2 import os 3 4 def attachDeviceList(): 5 device_list = [] 6 cmd_output = os.popen("adb devices","r").read().split()[4:] # 从输出的列表中第5个开始为设备序列号,将后面所有内容全部输出 7 for i in

iOS 获取沙盒路径方法

//获取家目录路径的函数: NSString *homeDir = NSHomeDirectory(); //获取Documents目录路径的方法: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docDir = [paths objectAtIndex:0]; //获取Caches目录路径的方法: NSArray *paths

iOS 获取手机的型号,系统版本,软件名称,软件版本

应用程序的名称和版本号等信息都保存在mainBundle的一个字典中,用下面代码可以取出来. NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];NSString* versionNum =[infoDict objectForKey:@"CFBundleVersion"];NSString*appName =[infoDict objectForKey:@"CFBundleDisplayName&qu

iOS xcode6最新提交app方法

依照之前方式打包.打包成功后.直接submit提交AppStore.然后再选择build,假设上传成功,但在build选择上未出现,你能够耐心等待.有可能要等上一天,然后选择相应的build,直接提交.

iOS 获取当前设备类

.h // // GetDevices.h // 1000colors // // Created by HO on 16/6/12. // Copyright © 2016年 HO. All rights reserved. // #import <Foundation/Foundation.h> @interface GetDevices : NSObject + (NSString*)deviceString; @end .m // // GetDevices.m // 1000colo

swift 获取iphone设备型号

//MARK: - UIDevice延展 public extension UIDevice { var modelName: String { var systemInfo = utsname() uname(&systemInfo) let machineMirror = Mirror(reflecting: systemInfo.machine) let identifier = machineMirror.children.reduce("") { identifier