iPhone设备的世代

3
我有以下代码。
@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)等?

谢谢, Biranchi


NSString+stringWithCStringе·Іиў«ејғз”ЁпјҢжӮЁеә”иҜҘдҪҝз”ЁNSString+stringWithCString:encodingгҖӮ - zekel
2个回答

7
: iPhone (原始版)
: iPhone 3G
: iPhone 3GS
: iPhone 4
: iPhone 4S

: iPod touch (原始版)
: iPod touch (第二代)
: iPod touch (第三代)
: iPod touch (第四代)

: iPad (原始版)
: iPad 2
: iPad (第三代)


-2

硬件版本。把它们看作平台的一个版本。您还可以从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]);

...等等。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接