获取设备型号、app信息、系统信息

一、 获取设备型号的方法主要有三种:

///===== 设备型号:方法一 ========

NSString * strModel  = [UIDevice currentDevice].model;
NSLog(@"model:%@",strModel);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);

//===== 设备型号:方法二 =========

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

//===== 设备型号:方法三 (model)=========

size_t size;
sysctlbyname ("hw.machine" , NULL , &size ,NULL ,0);
char *model = (char *)malloc(size);
sysctlbyname ("hw.machine" , model , &size ,NULL ,0);
NSString * strModel3 = [NSString stringWithCString: model encoding:NSUTF8StringEncoding];
free(model);
NSLog(@"hw.machine-model:%@",strModel3);

//===== 设备型号:方法三 (machine)=========

char *machine = (char*)malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
 NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
free(machine);
NSLog(@"hw.machine-platform:%@",platform);
原文地址:https://www.cnblogs.com/newBlash/p/4288138.html