Tuesday, February 2, 2010

How to determine Which model of iphone/ipod used

Include these classes

#include "sys/types.h"

#include "sys/sysctl.h"



Use this method for the Determine platform.

#pragma mark -

- (NSString *) platform

{

size_t size;

sysctlbyname("hw.machine", NULL, &size, NULL, 0);

char *machine = malloc(size);

sysctlbyname("hw.machine", machine, &size, NULL, 0);

/*

Possible values:

"iPhone1,1" = iPhone 1G

"iPhone1,2" = iPhone 3G

"iPhone2,1" = iPhone 3GS

"iPod1,1" = iPod touch 1G

"iPod2,1" = iPod touch 2G

*/

NSString *platform = [NSString stringWithCString:machine];

free(machine);

return platform;

}


No comments:

Post a Comment