remove duplicate code
This commit is contained in:
parent
ff5c065eae
commit
1e7076d9f8
@ -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)
|
||||
}()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user