Skip to content

mukeshthawani/Device.swift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 81.9%
  • Ruby 10.2%
  • Objective-C 7.9%