【问题标题】:How can I get the internal name on iOS?如何在 iOS 上获取内部名称?
【发布时间】:2016-08-13 12:56:13
【问题描述】:

我需要获取 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

【问题讨论】:

    标签: ios iphone xcode cpu processors


    【解决方案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。它针对 Swift,但在 Objective-C 中调用 sysctl 应该更容易。

    【讨论】:

      【解决方案2】:

      获取内部名称的示例代码,例如 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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-15
        • 1970-01-01
        • 2015-05-22
        相关资源
        最近更新 更多