gpt4 book ai didi

ios - 有没有办法使用 sysctl 获取 iPhone 型号?

转载 作者:行者123 更新时间:2023-12-01 18:08:20 30 4
gpt4 key购买 nike

我需要获取型号,例如:对于 iPhone 6,我想要的型号是 N61AP 而不是 iPhone 7,2。我在objective-c中需要这个。
我尝试了一些方法,但我得到的只是'iPhone 7,2' :(
如果没有办法收集这个,有没有办法得到 CPU 供应商?谢谢!

最佳答案

尝试添加这个(任何地方都可以,也许是应用程序委托(delegate)):

+ (NSString *)model
{
size_t size;
sysctlbyname("hw.model", NULL, &size, NULL, 0);
char *model = malloc(size);
sysctlbyname("hw.model", model, &size, NULL, 0);
NSString *modelString = [NSString stringWithUTF8String:model]; // could also use shorthand wrapper: '@(model)'
free(model);
return modelString;
}

对于我的 iPad Air 设备,这给了我“J71AP”。

如果您真的想要实际设备名称(即“iPhone7,2”,或者在我的情况下为“iPad4,1”),将“hw.model”替换为“hw.machine”将为您提供。

关于ios - 有没有办法使用 sysctl 获取 iPhone 型号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36875327/

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