IPhone device

I have the following code

@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]);

I get output like:

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

that the two numbers added after iphone / ipod touch are i, e (1,1), (1,2), etc.

Thanks Biranchi

+3
source share
2 answers

iPhone1.1 : iPhone (original)
iPhone1.2 : iPhone 3G
iPhone2.1 : iPhone 3GS
iPhone3.1 : iPhone 4
iPhone4.1 : iPhone 4S

iPod1.1 : iPod touch (original)
iPod2.1 : iPod touch (second generation)
iPod3.1 : iPod touch (3rd generation)
iPod4.1 : iPod touch (4th generation)

iPad1,1: iPad ()
iPad2,1: iPad 2
iPad3,1: iPad (3- )

+7

. . 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]);

... ...

-2

Source: https://habr.com/ru/post/1722549/


All Articles