remove duplicate code

master
Jordan Koch 2019-11-20 14:59:29 -05:00
parent ff5c065eae
commit 1e7076d9f8
1 changed files with 2 additions and 10 deletions

View File

@ -9,7 +9,7 @@ import UIKit
import Foundation
public class UIDeviceModelNames {
public static let modelUglyName: String = {
public static let hardwareIdentifier: String = {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
@ -22,14 +22,6 @@ public class UIDeviceModelNames {
}()
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
#if os(iOS)
switch identifier {
@ -92,6 +84,6 @@ public class UIDeviceModelNames {
#endif
}
return mapToDevice(identifier: identifier)
return mapToDevice(identifier: hardwareIdentifier)
}()
}