remove duplicate code
This commit is contained in:
parent
ff5c065eae
commit
1e7076d9f8
@ -9,7 +9,7 @@ import UIKit
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class UIDeviceModelNames {
|
public class UIDeviceModelNames {
|
||||||
public static let modelUglyName: String = {
|
public static let hardwareIdentifier: String = {
|
||||||
var systemInfo = utsname()
|
var systemInfo = utsname()
|
||||||
uname(&systemInfo)
|
uname(&systemInfo)
|
||||||
let machineMirror = Mirror(reflecting: systemInfo.machine)
|
let machineMirror = Mirror(reflecting: systemInfo.machine)
|
||||||
@ -22,14 +22,6 @@ public class UIDeviceModelNames {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
public static let modelName: String = {
|
public static let modelName: String = {
|
||||||
var systemInfo = utsname()
|
|
||||||
uname(&systemInfo)
|
|
||||||
let machineMirror = Mirror(reflecting: systemInfo.machine)
|
|
||||||
let identifier = machineMirror.children.reduce("") { identifier, element in
|
|
||||||
guard let value = element.value as? Int8, value != 0 else { return identifier }
|
|
||||||
return identifier + String(UnicodeScalar(UInt8(value)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func mapToDevice(identifier: String) -> String { // swiftlint:disable:this cyclomatic_complexity
|
func mapToDevice(identifier: String) -> String { // swiftlint:disable:this cyclomatic_complexity
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
switch identifier {
|
switch identifier {
|
||||||
@ -92,6 +84,6 @@ public class UIDeviceModelNames {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapToDevice(identifier: identifier)
|
return mapToDevice(identifier: hardwareIdentifier)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user