Skip to content

Instantly share code, notes, and snippets.

View larsacus's full-sized avatar

Lars Anderson larsacus

View GitHub Profile
@larsacus
larsacus / FetchIOSModelCode.m
Created August 17, 2011 16:21
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);