Skip to content

A wrapper for UIDevice that provides quick access to all necessary information about current Device. Written in Swift

License

Notifications You must be signed in to change notification settings

HiDaN4/DSDeviceKit

Repository files navigation

DSDeviceKit

[![CI Status](http://img.shields.io/travis/Dmitry Sokolov/DSDeviceKit.svg?style=flat)](https://travis-ci.org/Dmitry Sokolov/DSDeviceKit) Version License Platform

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.

About

A wrapper for UIDevice that provides quick access to all necessary information about current Device. Written in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published