UIDevice currentDevice model possible values,

來源:互聯網
上載者:User

UIDevice currentDevice model possible values,

NOTE: The below code may not contain all device's string, I'm with other guys are maintaining the same code on GitHub so please take the latest code from there

Objective-C : GitHub/DeviceUtil

Swift : GitHub/DeviceGuru

#include <sys/types.h>#include <sys/sysctl.h>- (NSString*)hardwareDescription {    NSString *hardware = [self hardwareString];    if ([hardware isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";    if ([hardware isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";    if ([hardware isEqualToString:@"iPhone3,1"]) return @"iPhone 4";    if ([hardware isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";    if ([hardware isEqualToString:@"iPhone5,1"]) return @"iPhone 5";    if ([hardware isEqualToString:@"iPod1,1"]) return @"iPodTouch 1G";    if ([hardware isEqualToString:@"iPod2,1"]) return @"iPodTouch 2G";    if ([hardware isEqualToString:@"iPad1,1"]) return @"iPad";    if ([hardware isEqualToString:@"iPad2,6"]) return @"iPad Mini";    if ([hardware isEqualToString:@"iPad4,1"]) return @"iPad Air WIFI";    //there are lots of other strings too, checkout the github repo    //link is given at the top of this answer    if ([hardware isEqualToString:@"i386"]) return @"Simulator";    if ([hardware isEqualToString:@"x86_64"]) return @"Simulator";    return nil;}- (NSString*)hardwareString {    size_t size = 100;    char *hw_machine = malloc(size);    int name[] = {CTL_HW,HW_MACHINE};    sysctl(name, 2, hw_machine, &size, NULL, 0);    NSString *hardware = [NSString stringWithUTF8String:hw_machine];    free(hw_machine);    return hardware;}

 原文連結:https://stackoverflow.com/questions/14411075/uidevice-currentdevice-model-possible-values

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.