Skip to content

Instantly share code, notes, and snippets.

@cburrows
Created October 7, 2015 15:46
Show Gist options
  • Save cburrows/b9f6f5ff0f8c71597be7 to your computer and use it in GitHub Desktop.
Save cburrows/b9f6f5ff0f8c71597be7 to your computer and use it in GitHub Desktop.
Detect CPU model on an iPhone
// Replace ViewController.m with this in a new "Single View Application"
#include <sys/sysctl.h>
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
size_t size;
sysctlbyname("hw.model", NULL, &size, NULL, 0);
char *value = malloc(size);
sysctlbyname("hw.model", value, &size, NULL, 0);
NSLog(@"%s", value);
free(value);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment