zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    EF
    采用什么架构,才能够承受大访问量
    13个MVC的扩展
    c#与.NET的区别
    整合Spring.net到asp.net网站开发中初探
    C#多线程编程简述
    ASP.NET页面传值的几种方式
    正则RegEXp
    C#中Cache用法
    c#程序将excel文件转换成xml文件
  • 原文地址:https://www.cnblogs.com/lurenq/p/7551711.html
Copyright © 2011-2022 走看看