Skip to content

Latest commit

 

History

History
88 lines (76 loc) · 1.54 KB

OSX.md

File metadata and controls

88 lines (76 loc) · 1.54 KB

Device family

Simple code:

func OSXDeviceFamily() {
    let family = Device.family()
    switch family {
    case .MacBookPro:
        print("Device belong to \(family) family")
    default:
        print("unknown Device.")
    }
}

Demo code: Family Demo Code

Device model

Simple code:

func OSXDeviceModel() {
    let model = Device.model()
    print(model.identifier)
    switch model {
    case .MacPro2017Early:
        print("Device is a \(model)")
    case .unknown:
        print("unknown Device.")
    }
}

Demo code: Model Demo Code

Device screen size

Simple code:

func OSXDeviceSize() {
    let size = Device.size()
    switch size {
    case .screen15Inch:
        print("Device size: \(size.description)")
    case .unknown:
        print("Device size unknown.")
    }
}

Demo code: Size Demo Code

Helpers

Model

Simple code:

func OSXModelHelper() {
    let model = Device.model()
    let allMacBookProes = Device.Model.allMacBookProes
    if allMacBookProes.contains(model) {
        print("Current device belong to MacBookPro ")
    }
}

Demo code: Model Helper Demo Code

Size

You can use operator like >, <, >=, <=, ==, !=

Simple code:

func OSXSizeHelper() {
    let size = Device.size()

    if size == .screen15Inch {
        print("It's a 15 inch screen")
    }

    if Device.isRetina() {
        print("It's a retina display")
    }
}

Demo code: Size Helper Demo Code