概述#include <sys/types.h> #include <sys/sysctl.h> //根据不同判断,确定出
硬件版本号 - (void)showPlatform { int mib[2]; size_t len; char *machine; mib[0] = CTL_HW; mib[1] = HW_MACHINE; sysctl(mib, 2, NULL, &len, NULL, 0) #include <sys/types.h> #include <sys/sysctl.h> //根据不同判断,确定出硬件
版本号 - (voID)showPlatform { int mib[2]; size_t len; char *machine; mib[0] = CTL_HW; mib[1] = HW_MACHINE; sysctl(mib, 2, NulL, &len, 0); machine = malloc(len); sysctl(mib, machine, 0); Nsstring *platform = [Nsstring stringWithCString:machine enCoding:NSASCIIStringEnCoding]; free(machine); if ([platform isEqualToString:@"iPhone1,1"]) platform = @"iPhone 1G"; if ([platform isEqualToString:@"iPhone1,2"]) platform = @"iPhone 3G"; if ([platform isEqualToString:@"iPhone2,1"]) platform = @"iPhone 3GS"; if ([platform isEqualToString:@"iPhone3,1"]) platform = @"iPhone 4"; if ([platform isEqualToString:@"iPod1,1"]) platform = @"iPod touch 1G"; if ([platform isEqualToString:@"iPod2,1"]) platform = @"iPod touch 2G"; if ([platform isEqualToString:@"iPod3,1"]) platform = @"iPod touch 3G"; if ([platform isEqualToString:@"iPod4,1"]) platform = @"iPod touch 4G"; if ([platform isEqualToString:@"iPad1,1"]) platform = @"iPad"; if ([platform isEqualToString:@"iPad2,1"]) platform = @"iPad 2 (WiFi)"; if ([platform isEqualToString:@"iPad2,2"]) platform = @"iPad 2 (GSM)"; if ([platform isEqualToString:@"iPad2,3"]) platform = @"iPad 2 (CDMA)"; if ([platform isEqualToString:@"i386"]) platform = @"Simulator"; NSLog(@"Device:%@",platform); } 总结
以上是内存溢出为你收集整理的检测硬件平台版本号全部内容,希望文章能够帮你解决检测硬件平台版本号所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
评论列表(0条)