zoukankan      html  css  js  c++  java
  • 获取IOS硬件设备的型号 沧海一粟

     1 /*
     2  *  获取版本型号
     3  *  "i386"          simulator
     4  *  "iPod1,1"       iPod Touch
     5  *  "iPhone1,1"     iPhone
     6  *  "iPhone1,2"     iPhone 3G
     7  *  "iPhone2,1"     iPhone 3GS
     8  *  "iPad1,1"       iPad
     9  *  "iPhone3,1"     iPhone 4
    10  */
    11 +(NSString *)deviceString;
    12 
    13 
    14 
    15 
    16 +(NSString*)deviceString
    17 {
    18     struct utsname systemInfo;
    19     uname(&systemInfo);
    20     NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    21     
    22     if ([deviceString isEqualToString:@"iPhone1,1"])    return @"iPhone 1G";
    23     if ([deviceString isEqualToString:@"iPhone1,2"])    return @"iPhone 3G";
    24     if ([deviceString isEqualToString:@"iPhone2,1"])    return @"iPhone 3GS";
    25     if ([deviceString isEqualToString:@"iPhone3,1"])    return @"iPhone 4";
    26     if ([deviceString isEqualToString:@"iPhone3,2"])    return @"Verizon iPhone 4";
    27     if ([deviceString isEqualToString:@"iPod1,1"])      return @"iPod Touch 1G";
    28     if ([deviceString isEqualToString:@"iPod2,1"])      return @"iPod Touch 2G";
    29     if ([deviceString isEqualToString:@"iPod3,1"])      return @"iPod Touch 3G";
    30     if ([deviceString isEqualToString:@"iPod4,1"])      return @"iPod Touch 4G";
    31     if ([deviceString isEqualToString:@"iPad1,1"])      return @"iPad";
    32     if ([deviceString isEqualToString:@"iPad2,1"])      return @"iPad 2 (WiFi)";
    33     if ([deviceString isEqualToString:@"iPad2,2"])      return @"iPad 2 (GSM)";
    34     if ([deviceString isEqualToString:@"iPad2,3"])      return @"iPad 2 (CDMA)";
    35     if ([deviceString isEqualToString:@"i386"])         return @"Simulator";
    36     if ([deviceString isEqualToString:@"x86_64"])       return @"Simulator";
    37 
    38     DLog(@"NOTE: Unknown device type: %@", deviceString);
    39     return deviceString;
    40 }
  • 相关阅读:
    字符数组与指针
    终于在博客园安家了
    关于SET NOCOUNT
    如何判断请求是否发送成功以及获取请求中的数据
    mysql进阶 withas 性能调优
    Linux mkdir
    Linux umask and chmod
    C linux Debug
    Linux sed
    Linux ulimit
  • 原文地址:https://www.cnblogs.com/taintain1984/p/2845224.html
Copyright © 2011-2022 走看看