Skip to content

Instantly share code, notes, and snippets.

@larsacus
Created August 17, 2011 16:21
Show Gist options
  • Save larsacus/1151923 to your computer and use it in GitHub Desktop.
Save larsacus/1151923 to your computer and use it in GitHub Desktop.
Fetches exact model code of iOS device for logging
#include <sys/types.h>
#include <sys/sysctl.h>
- (NSString *)hardwareDeviceModelCode{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
free(machine);
return platform;
}
//http://stackoverflow.com/questions/1108859/detect-the-specific-iphone-ipod-touch-model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment