Skip to content

zhuxiaod/UIDeviceModel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UIDeviceModel

Language License Pod Version Carthage Compatible

A µframework to detect the device model provided through an extension of UIDevice. It also allows detection of the simulator and the device model it is simulating.

Installation

CocoaPods

pod 'UIDeviceModel', '~> 1.0'

Carthage

github "theoriginalbit/UIDeviceModel"

Usage

First import the framework:

import UIDeviceModel

Common usage would be to use in a switch statement

let deviceModel = UIDevice.current.deviceModel

switch deviceModel {
case .iPhone6sPlus: break // You're on an iPhone 6s Plus
case .iPhoneXS: break // You're on an iPhone XS
case .simulator: break // Oh, hello there developer!
default: break
}

If needed you can unwrap a simulator to get the device model being simulated

let deviceModel = UIDevice.current.deviceModel.unwrapIfSimulator

// Or as an enum

switch deviceModel {
case .simulator(let simulatedDeviceModel): break // It's as if it never happened
default: break
}

About

A µframework to detect the device model.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Swift 76.8%
  • Ruby 15.5%
  • Objective-C 7.7%