iphone開發:獲取設備型號iPhone軟體開發教學課程

+ (NSString *)getPhoneModel
{
    size_t size;
   
    // get the length of machine name
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
   
    // get machine name
    char *machine = (char*)malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithCString:machine encoding:NSASCIIStringEncoding];
    free(machine);
   
    return platform;
}

 

 

摘自 雲懷空-abel

You May Also Like