From 1e7076d9f811205175d0494d7ec32f3f813f81ae Mon Sep 17 00:00:00 2001 From: Jordan Koch Date: Wed, 20 Nov 2019 14:59:29 -0500 Subject: [PATCH] remove duplicate code --- UIDeviceModelNames/Classes/UIDeviceModelNames.swift | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/UIDeviceModelNames/Classes/UIDeviceModelNames.swift b/UIDeviceModelNames/Classes/UIDeviceModelNames.swift index 446fd84..969fa4e 100644 --- a/UIDeviceModelNames/Classes/UIDeviceModelNames.swift +++ b/UIDeviceModelNames/Classes/UIDeviceModelNames.swift @@ -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) }() }