DeviceDetector 0.2.0

DeviceDetector 0.2.0

Zaakk维护。



  • Zaakk

DeviceDetector

DeviceDetector 能够检测设备型号和蜂窝类型。

支持的设备

  1. iPhone
  2. iPad
  3. AppleTV
  4. Apple Watch

使用方法

导入模块

import DeviceDetector

然后您可以直接在条件或 switch-case 中检查当前设备

if DeviceDetector.device.is(iPadModel.Model2(cellularType: .CDMA))
{
  print("is iPad2")
}

if DeviceDetector.device.younger(iPhoneModel.Model3G(cellularType: .CDMA))
{
  print("Current device is younger than iPhone 3G")
}

if case iPhoneModel.Model3G(cellularType: let cellular) = DeviceDetector.device, cellular == .GSM
{
    print("The device is iPhone 3G AND GSM")
}

安装

DeviceDetector 可通过 CocoaPods 获取。要安装它,只需将以下行添加到 Podfile 中

pod 'DeviceDetector'

或者,复制 DeviceDetector 文件夹。如果使用此方法,则可以省略文件头部 "import DeviceDetector" 的行。

作者

Alexander Zakatnov,[email protected]