DSDeviceKit 0.1.2

DSDeviceKit 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jul 2016
SPMSupports SPM

Maintained by Dmitry Sokolov.




  • By
  • Dmitry Sokolov

DSDeviceKit

Overview

A wrapper for UIDevice that provides quick access to all necessary information about current Device. Implements the Singleton Pattern

Requirements

  • ARC
  • iOS 8 (dynamic framework)

Installation

DSDeviceKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "DSDeviceKit"

Usage

import DSDeviceKit

let device = DSDeviceKit.currentDevice

print(device.modelName)     // "iPhone 6s" or "iPad Air 2" and so on
print(device.identifier)    // "iPhone8,1" or "Simulator" and so on
print(device.iOSVersion)    // "9.3" and so on
print(device.deviceType)    // "iPhone" or "iPad" or "iPod Touch" or "Unknown"
print(device.isPhone)       // true or false

let devices = ["iphone 6", "ipad pro", "iPhone SE"]


if device.isOneOf(devices) {
    // is one of the allowed devices
}


if device.deviceType == .iPodTouch { // or .iPhone or .iPad
    // ...
}

// or you can use convenient computed variables:

if device.isPhone {
    // this is iPhone
}


if device.isIPad {
    // this is iPad
}

Example project

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Dmitry Sokolov

License

DSDeviceKit is available under the MIT license. See the LICENSE file for more info.