Latest 1.1.0
Homepage https://github.com/theoriginalbit/UIDeviceModel
License MIT
Platforms ios 8.0, requires ARC
Authors

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
}

Latest podspec

{
    "name": "UIDeviceModel",
    "version": "1.1.0",
    "summary": "A u00b5framework to detect the device model.",
    "description": "A u00b5framework 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.",
    "homepage": "https://github.com/theoriginalbit/UIDeviceModel",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "theoriginalbit": "[email protected]"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/theoriginalbit/UIDeviceModel.git",
        "tag": "1.1.0"
    },
    "source_files": [
        "Source",
        "Source/**/*.{h,swift}"
    ],
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This