-1

I am using this code to identify the iPhone Device. Can anyone explain to me how to call and get the current device version?

How to call one of these methods?

+ (DeviceHardwareSpecificPlatform)specificPlatform;
+ (DeviceHardwareGeneralPlatform)generalPlatform;
+ (DeviceHardwarePlatformType)platformType;
+ (NSString *)platformString;

I am calling them from another class.

Szu
  • 2,254
  • 1
  • 21
  • 37
user3189586
  • 125
  • 1
  • 8

2 Answers2

0

According to the link you gave, there is a usage.txt file

UIDeviceHardware *h=[[UIDeviceHardware alloc] init];
[self setDeviceModel:[h platformString]];
[h release];

Actually, it's an old piece of code with manually managed memory. With ARC, you may want to use:

UIDeviceHardware *h=[[UIDeviceHardware alloc] init];
[self setDeviceModel:[h platformString]];
Imotep
  • 2,006
  • 2
  • 25
  • 38
0

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     
Teja Kumar Bethina
  • 3,486
  • 26
  • 34