代码之家  ›  专栏  ›  技术社区  ›  Biranchi

iPhone设备生成

  •  3
  • Biranchi  · 技术社区  · 15 年前

    我有以下代码

    @implementation UIDevice(machine)
    
    - (NSString *)machine
    {
      size_t size;
    
      // Set 'oldp' parameter to NULL to get the size of the data
      // returned so we can allocate appropriate amount of space
      sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
    
      // Allocate the space to store name
      char *name = malloc(size);
    
      // Get the platform name
      sysctlbyname("hw.machine", name, &size, NULL, 0);
    
      // Place name into a string
      NSString *machine = [NSString stringWithCString:name];
    
      // Done with this
      free(name);
    
      return machine;
    }
    
    @end
    
    /* ... */
    
    NSLog(@"device: %@", [[UIDevice currentDevice] machine]);
    

    我得到的输出为:

    Platforms:
    -----------
    iPhone1,1 
    iPhone1,2 
    iPod1,1   
    iPod2,1   
    

    在iPhone/iPod touch后面附加的两个数字表示什么,即(1,1)、(1,2)等?

    谢谢 比兰奇

    2 回复  |  直到 13 年前
        1
  •  7
  •   Mehrdad Afshari    13 年前

    iPoE1,1 :iPhone(原版)
    iPoE1,2 :iPhone 3G
    iPoe2,1 iPhone 3GS
    iPoe3,1 iPhone 4
    iPhone4、1 iPhone 4S

    IPOD1,1 :iPod touch(原始)
    IPOD2,1 :iPod touch(第2代)
    IPOD3,1 :iPod touch(第三代)
    IPOD4,1 :iPod touch(第4代)

    IPAD1,1 :iPad(原版)
    IPAD2.1 iPad 2
    IPAD3.1 :iPad(第三代)

        2
  •  -2
  •   Jed Smith    15 年前

    硬件修订。把它们看作是平台的一个版本。您也可以从 UIDevice 你为什么这么低?

    试试这个:

    UIDevice *dev = [UIDevice currentDevice];
    NSLog(@"Information for device '%@' (UDID '%@')", [dev name], [dev uniqueIdentifier]);
    NSLog(@"Model: %@", [dev model]);
    NSLog(@"OS: %@ version %@", [dev systemName], [dev systemVersion]);
    

    ……等