Skip to content

Instantly share code, notes, and snippets.

View xumeng's full-sized avatar
😇
Open to work

Meng Xu xumeng

😇
Open to work
View GitHub Profile
@xumeng
xumeng / iOS_Hardware_Model.txt
Last active November 2, 2017 02:54
Basic code to get the Hardware Model of an iOS device in Objective-C. https://en.wikipedia.org/wiki/List_of_iOS_devices
// #import "sys/utsname.h"
struct utsname systemInfo;
uname(&systemInfo);
NSString *deviceString = [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
//iPhone
if ([deviceString isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([deviceString isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([deviceString isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";