1

我需要在 iOS 上获取 CPU 信息。我是通过代码 iPhone8,1(这是 iPhone 6s)来实现的,但 iPhone 6s、6s plus 和 iPhone SE 有两个不同的处理器,一个是三星(N69uAP),另一个是台积电(N69AP)。我需要知道我正在使用的手机中使用的是什么处理器,有谁知道在这种情况下我该如何区分它们?我唯一知道的是这些代码不同(N69uAP 和 N69AP),但我不知道如何获得它们。这就是我在每个型号只有一个处理器的旧 iPhone 中所做的:

if (([platform isEqualToString:@"iPhone7,1"]) ||([platform isEqualToString:@"iPhone7,2"]))
    return @"T7000";
//this is iPhone 6 

我获得有关 iPhone 信息的网站:https ://www.theiphonewiki.com/wiki/Models#iPhone

4

2 回答 2

1

只是一个想法,但也许sysctl可以提供帮助。在我的 Mac 上运行sysctl会返回如下信息(在许多其他行中):

$ sysctl -A | grep cpu ... hw.cputype: 7 hw.cpusubtype: 8 hw.cpufamily: 280134364 hw.cpufrequency: 2600000000 machdep.cpu.vendor: GenuineIntel machdep.cpu.brand_string: Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz machdep.cpu.family: 6 machdep.cpu.model: 70 machdep.cpu.extmodel: 4 machdep.cpu.extfamily: 0 ...

我还没有测试过 iOS 上是否有相同的信息,但我认为值得一试。Matt Gallagher 的文章Gathering system information in Swift with sysctl可能有助于了解如何调用sysctl. sysctl它针对 Swift,但在 Objective-C中调用应该更容易。

于 2016-04-21T09:18:18.217 回答
0

示例代码只是为了获得内部名称,如iPhone7,1

#import <sys/utsname.h>

@interface UIDevice (InternalName)
- (NSString*) internalModelName;
@end

@implementation UIDevice (InternalName)
- (NSString*) internalModelName {
    struct utsname systemInfo;
    uname(&systemInfo);
    return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}
@end
于 2018-11-21T13:18:00.070 回答