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
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
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
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
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