device-kit 1.1.1

device-kit 1.1.1

Astemir Eleev维护。



  • 作者:
  • Astemir Eleev

device-kit Awesome

Platforms Language CocoaPod Build Status codecov License

最后更新:2019年4月6日。

如果您喜欢这个项目,请给它一个星 ⭐ 这将向创建者展示您的认可,并帮助他人发现此代码库。

✍️关于

📱一个框架,允许获取iOS设备的扩展信息。

🏗安装

CocoaPods

device-kit可通过CocoaPods获取

pod 'device-kit', '~> 1.1.1' 

手动

您始终可以使用复制粘贴源代码的方法😄. 或者,您可以编译该框架并将其包含到您的项目中。

📚功能

  • 设备类型信息
    • 轻松获取设备的标识符
    • 确定一个应用是在模拟器上运行还是在实际的设备上运行
    • 包含有关每个iOS设备的详细信息
  • 设备存储状态,例如:
    • 总空间
    • 空闲空间
    • 已用空间
    • 您可以使用各种单位(通过使用ByteCountFormatter.Units)来格式化数据
  • 设备方向信息
    • 无需调用示例代码UIDevice.current.orientation或进行if/else检查,即可检查设备是否处于.portrait.landscape方向
    • 如果您愿意,可以使用isPortrait属性
  • 设备互联网连接状态
    • 轻松检查您的设备是否已连接到互联网
    • 您还可以获取可达性状态

✈️用途

获取设备的标识符

let identifiers = UIDevice.current.deviceType
// `identifiers` will hold the corresponding devices' identifiers depending on your `iOS` model

确定剩余多少存储空间

UIDevice.current.storageStatus.getFreeSpace(.useMB)
// Will print something like this:
// 139,197.3 MB

UIDevice.current.storageStatus.getFreeSpace(.useGB)
// Or you can change the unit type to Gigabytes:
// 139.16 GB

UIDevice.current.storageStatus.getFreeSpace(.useGB, includeUnitPostfix: false)
// If you don't want to get GB, MB postfixes then specify an optional parameter for `includeUnitPostfix`:
// 139.16

检查设备的方向

let orienation = UIDevice.current.deviceOrientation

switch orientation {
  case .portrait:
    showDrawerView()
  case .landscape:
    hideDrawerView()
}

获取互联网连接状态

let internet = UIDevice.current.internetConnection

guard internet.connection == .open else { 
  throw NetworkError.isNotAvailabe("Missing internet connection")
}

sendRequest()

📝待办事项

  • 轻量级Network可达性(带有NotificationCenter支持或更安全的更改观察方法)
    • NotificationCenter观察者支持
  • 设备方向
    • NotificationCenter观察者支持
  • 界面方向
    • NotificationCenter观察者支持

🙋‍♀️🙋‍♂️贡献

  • 对于贡献者来说,只有一条主要规则 - 请将您的扩展放在独立的文件中。这是因为此类扩展可以更容易地被引用和重用。
  • 另一条软性规则是 - 请与您的扩展一起包含单元测试

👨‍💻作者

Astemir Eleev

🔖许可

该项目在MIT许可证下提供