zhouhao27 / Device.swift

Super-lightweight library to detect used device

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Device.swift Carthage compatible

Super-lightweight library to detect used device

Usage

Device.swift extends the UIDevice class by adding a deviceType: DeviceType property.

import Device_swift

let deviceType = UIDevice.currentDevice().deviceType

switch deviceType {
case .IPhone6SPlus: print("Do stuff for iPhone6S Plus")
case .IPadMini: print("Do stuff for iPad mini")
default: print("Check other available cases of DeviceType")
}

Available DeviceType cases

enum DeviceType {
    case NotAvailable

    case IPhone2G
    case IPhone3G
    case IPhone3GS
    case IPhone4
    case IPhone4S
    case IPhone5
    case IPhone5C
    case IPhone5S
    case IPhone6Plus
    case IPhone6
    case IPhone6S
    case IPhone6SPlus

    case IPodTouch1G
    case IPodTouch2G
    case IPodTouch3G
    case IPodTouch4G
    case IPodTouch5G

    case IPad
    case IPad2
    case IPad3
    case IPad4
    case IPadMini
    case IPadMiniRetina
    case IPadMini3

    case IPadAir
    case IPadAir2

    case Simulator
}

Install

Carthage

Add the following to your Cartfile and follow these instructions

github "schickling/Device.swift"

CocoaPods

CocoaPods 0.36 adds supports for Swift and embedded frameworks. To integrate Device into your project add the following to your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'Device.swift'

About

Super-lightweight library to detect used device

License:MIT License


Languages

Language:Swift 78.9%Language:Ruby 11.9%Language:Objective-C 9.2%