美文网首页
iOS 获取设备型号

iOS 获取设备型号

作者: 爱哭的僵小鱼 | 来源:发表于2020-05-29 09:47 被阅读0次

    /**
    获取设备名称
    */

    • (NSString *)iphoneName
      {
      struct utsname systemInfo;
      uname(&systemInfo); // 获取系统设备信息
      NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];

      NSDictionary *dict = @{
      // iPhone
      @"iPhone5,3" : @"iPhone 5c",
      @"iPhone5,4" : @"iPhone 5c",
      @"iPhone6,1" : @"iPhone 5s",
      @"iPhone6,2" : @"iPhone 5s",
      @"iPhone7,1" : @"iPhone 6 Plus",
      @"iPhone7,2" : @"iPhone 6",
      @"iPhone8,1" : @"iPhone 6s",
      @"iPhone8,2" : @"iPhone 6s Plus",
      @"iPhone8,4" : @"iPhone SE",
      @"iPhone9,1" : @"iPhone 7",
      @"iPhone9,2" : @"iPhone 7 Plus",
      @"iPhone10,1" : @"iPhone 8",
      @"iPhone10,4" : @"iPhone 8",
      @"iPhone10,2" : @"iPhone 8 Plus",
      @"iPhone10,5" : @"iPhone 8 Plus",
      @"iPhone10,3" : @"iPhone X",
      @"iPhone10,6" : @"iPhone X",
      @"iPhone11,2" : @"iPhone XS",
      @"iPhone11,4" : @"iPhone XS Max",
      @"iPhone11,6" : @"iPhone XS Max",
      @"iPhone11,8" : @"iPhone XR",
      @"i386" : @"iPhone Simulator",
      @"x86_64" : @"iPhone Simulator",
      // iPad
      @"iPad4,1" : @"iPad Air",
      @"iPad4,2" : @"iPad Air",
      @"iPad4,3" : @"iPad Air",
      @"iPad5,3" : @"iPad Air 2",
      @"iPad5,4" : @"iPad Air 2",
      @"iPad6,7" : @"iPad Pro 12.9",
      @"iPad6,8" : @"iPad Pro 12.9",
      @"iPad6,3" : @"iPad Pro 9.7",
      @"iPad6,4" : @"iPad Pro 9.7",
      @"iPad6,11" : @"iPad 5",
      @"iPad6,12" : @"iPad 5",
      @"iPad7,1" : @"iPad Pro 12.9 inch 2nd gen",
      @"iPad7,2" : @"iPad Pro 12.9 inch 2nd gen",
      @"iPad7,3" : @"iPad Pro 10.5",
      @"iPad7,4" : @"iPad Pro 10.5",
      @"iPad7,5" : @"iPad 6",
      @"iPad7,6" : @"iPad 6",
      // iPad mini
      @"iPad2,5" : @"iPad mini",
      @"iPad2,6" : @"iPad mini",
      @"iPad2,7" : @"iPad mini",
      @"iPad4,4" : @"iPad mini 2",
      @"iPad4,5" : @"iPad mini 2",
      @"iPad4,6" : @"iPad mini 2",
      @"iPad4,7" : @"iPad mini 3",
      @"iPad4,8" : @"iPad mini 3",
      @"iPad4,9" : @"iPad mini 3",
      @"iPad5,1" : @"iPad mini 4",
      @"iPad5,2" : @"iPad mini 4",
      // Apple Watch
      @"Watch1,1" : @"Apple Watch",
      @"Watch1,2" : @"Apple Watch",
      @"Watch2,6" : @"Apple Watch Series 1",
      @"Watch2,7" : @"Apple Watch Series 1",
      @"Watch2,3" : @"Apple Watch Series 2",
      @"Watch2,4" : @"Apple Watch Series 2",
      @"Watch3,1" : @"Apple Watch Series 3",
      @"Watch3,2" : @"Apple Watch Series 3",
      @"Watch3,3" : @"Apple Watch Series 3",
      @"Watch3,4" : @"Apple Watch Series 3",
      @"Watch4,1" : @"Apple Watch Series 4",
      @"Watch4,2" : @"Apple Watch Series 4",
      @"Watch4,3" : @"Apple Watch Series 4",
      @"Watch4,4" : @"Apple Watch Series 4"
      };
      NSString *name = dict[platform];

      return name ? name : platform;
      }

    点击屏幕 产生轻微触感(震动反馈)
    if (@available(iOS 11.0, *))
    {
    UIImpactFeedbackGenerator *feedBackGenertor = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight];
    [feedBackGenertor impactOccurred];
    }

    打开终端,用cd命令 定位到工程所在的目录,然后调用以下命名即可把每个源代码文件行数及总数统计出来:

    find . "(" -name ".m" -or -name ".mm" -or -name ".cpp" -or -name ".h" -or -name "*.rss" ")" -print | xargs wc -l

    相关文章

      网友评论

          本文标题:iOS 获取设备型号

          本文链接:https://www.haomeiwen.com/subject/lmtxzhtx.html