Wednesday 30 April 2014

Getting the device information using UIDevice

The UIDevice class provides all the information of the device on which your app is running.

UIDevice *deviceInfo = [UIDevice currentDevice]; 

NSLog(@“OS running on device: %@”, deviceInfo.systemName);
   // OS running on device: iPhone OS
NSLog(@“OS Version running on device:  %@”, deviceInfo.systemVersion);
  //OS Version running on device:  7.1
NSLog(@“Device model:  %@”, deviceInfo.model);   
  // Device model:  iPod touch

size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *deviceModelVersion = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
free(machine);

NSLog(@"Device model version: %@", deviceModelVersion);
//Device model version: iPhone4, 1

NSLog(@“Device name:  %@”, deviceInfo.name); 
  //Device name:  my iPod 

No comments:

Post a Comment