tags:

views:

79

answers:

2

Hi ,

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 am getting the output as:

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

what does the two numbers appended after the iphone/ipod touch signify i,e (1,1 ) , (1,2) etc ?

Thanks Biranchi

A: 

Hardware revisions. Think of them as a version of the platform. You can also get this information from UIDevice; why are you going so low-level?

Try this:

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

...etc.

Jed Smith
+4  A: 
  • iPhone1,1: First generation (2G) iPhone
  • iPhone1,2: iPhone 3G
  • iPhone2,1: iPhone 3GS
  • iPod1,1: First generation iPod touch
  • iPod2,1: Second generation iPod touch
  • iPod3,1: Third generation iPod touch
Mehrdad Afshari