Skip to content

Instantly share code, notes, and snippets.

Created November 28, 2013 21:37
What would you like to do?
Get the model identifier for the current device (on iOS or Mac)
#include <sys/types.h>
#include <sys/sysctl.h>
char *propertyName = "hw.machine";
char *propertyName = "hw.model";
size_t size;
// Mac: use 'hw.model'. On iOS use 'hw.machine'
sysctlbyname(propertyName, NULL, &size, NULL, 0);
char *model = malloc(size);
sysctlbyname(propertyName, model, &size, NULL, 0);
// model identifier as NSString
NSString *modelIdentifier = [NSString stringWithCString:model encoding:NSUTF8StringEncoding];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment