gpt4 book ai didi

iphone - 如何通过代码查找iPhone/iPod设备型号(3G、3GS、4、4S)?

转载 作者:行者123 更新时间:2023-12-03 18:38:13 26 4
gpt4 key购买 nike

Possible Duplicate:
Determine device (iPhone, iPod Touch) with iOS

我尝试获取当前的设备型号名称,例如 3G、3GS、4、4S、iPodTouch(不同代)。但是,到目前为止我还无法得到确切的结果。您能帮我查一下设备型号吗?这里我附上了我用来获取设备模型的代码。

UIDevice *device = [UIDevice currentDevice];
NSString *deviceVersion = [device systemVersion];//Return 4.0.1 and 5.0.1
NSString *deviceName = [device systemName];//Return iPhone, iPod Touch

如何获取设备型号3G、3GS、4、4S、iPod Touch、iPad?

最佳答案

#import <sys/utsname.h>

NSString*
machineName()
{
struct utsname systemInfo;
uname(&systemInfo);

return [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
}

结果应该是:

@"i386"      on the simulator
@"iPod1,1" on iPod Touch
@"iPod2,1" on iPod Touch Second Generation
@"iPod3,1" on iPod Touch Third Generation
@"iPod4,1" on iPod Touch Fourth Generation
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1" on iPad
@"iPad2,1" on iPad 2
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S

关于iphone - 如何通过代码查找iPhone/iPod设备型号(3G、3GS、4、4S)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8426518/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com