如何获得ios系统版本号,设备名称
1个回答
2015-02-08
展开全部
获得IOS系统版本号
[[[UIDevice currentDevice] systemVersion] floatValue]
获得硬件名称
+ (NSString*)getMachine{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *name = malloc(size);
sysctlbyname("hw.machine", name, &size, NULL, 0);
NSString *machine = [NSString stringWithCString:name encoding:NSUTF8StringEncoding];
free(name);
if( [machine isEqualToString:@"i386"] || [machine isEqualToString:@"x86_64"] ) machine = @"ios_Simulator";
else if( [machine isEqualToString:@"iPhone1,1"] ) machine = @"iPhone_1G";
else if( [machine isEqualToString:@"iPhone1,2"] ) machine = @"iPhone_3G";
else if( [machine isEqualToString:@"iPhone2,1"] ) machine = @"iPhone_3GS";
else if( [machine isEqualToString:@"iPhone3,1"] ) machine = @"iPhone_4";
else if( [machine isEqualToString:@"iPod1,1"] ) machine = @"iPod_Touch_1G";
else if( [machine isEqualToString:@"iPod2,1"] ) machine = @"iPod_Touch_2G";
else if( [machine isEqualToString:@"iPod3,1"] ) machine = @"iPod_Touch_3G";
else if( [machine isEqualToString:@"iPod4,1"] ) machine = @"iPod_Touch_4G";
else if( [machine isEqualToString:@"iPad1,1"] ) machine = @"iPad_1";
else if( [machine isEqualToString:@"iPad2,1"] ) machine = @"iPad_2";
return machine;
}
[[[UIDevice currentDevice] systemVersion] floatValue]
获得硬件名称
+ (NSString*)getMachine{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *name = malloc(size);
sysctlbyname("hw.machine", name, &size, NULL, 0);
NSString *machine = [NSString stringWithCString:name encoding:NSUTF8StringEncoding];
free(name);
if( [machine isEqualToString:@"i386"] || [machine isEqualToString:@"x86_64"] ) machine = @"ios_Simulator";
else if( [machine isEqualToString:@"iPhone1,1"] ) machine = @"iPhone_1G";
else if( [machine isEqualToString:@"iPhone1,2"] ) machine = @"iPhone_3G";
else if( [machine isEqualToString:@"iPhone2,1"] ) machine = @"iPhone_3GS";
else if( [machine isEqualToString:@"iPhone3,1"] ) machine = @"iPhone_4";
else if( [machine isEqualToString:@"iPod1,1"] ) machine = @"iPod_Touch_1G";
else if( [machine isEqualToString:@"iPod2,1"] ) machine = @"iPod_Touch_2G";
else if( [machine isEqualToString:@"iPod3,1"] ) machine = @"iPod_Touch_3G";
else if( [machine isEqualToString:@"iPod4,1"] ) machine = @"iPod_Touch_4G";
else if( [machine isEqualToString:@"iPad1,1"] ) machine = @"iPad_1";
else if( [machine isEqualToString:@"iPad2,1"] ) machine = @"iPad_2";
return machine;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询