1。添加头文件
#import <sys/utsname.h>
#import <sys/types.h>
#import <sys/sysctl.h>
2。 添加代码
struct utsname systemInfo;
uname(&systemInfo);
Nsstring *machinename = [Nsstring stringWithCString:systemInfo.machine enCoding:NSUTF8StringEnCoding];
if ([@"iPhone1,1" isEqualToString:machinename])
return iPhone_1;
else if ([@"iPhone1,2" isEqualToString:machinename])
return iPhone_3G;
else if ([@"iPhone2,1" isEqualToString:machinename])
return iPhone_3GS;
else if ([@"iPhone3,1" isEqualToString:machinename] || [@"iPhone3,2" isEqualToString:machinename] || [@"iPhone3,3" isEqualToString:machinename])
return iPhone_4;
else if ([@"iPod1,1" isEqualToString:machinename])
return iPod_1;
else if ([@"iPod2,1" isEqualToString:machinename] || [@"iPod2,2" isEqualToString:machinename])
return iPod_2;
else if ([@"iPod3,1" isEqualToString:machinename])
return iPod_3;
else if ([@"iPod4,1" isEqualToString:machinename])
return iPod_4;
else if (/*[@"iPad1,1" isEqualToString:machinename]*/[machinename hasPrefix:@"iPad"])
return iPad_1;
return unkNown;
总结以上是内存溢出为你收集整理的判断当前设备的类型 名全部内容,希望文章能够帮你解决判断当前设备的类型 名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)