Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve getType funcs #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Source/iOS/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ open class Device {
}

static fileprivate func getType(code: String) -> Type {
let versionCode = getVersionCode()

if versionCode.contains("iPhone") {
if code.contains(Type.iPhone.rawValue) {
return .iPhone
} else if versionCode.contains("iPad") {
} else if code.contains(Type.iPad.rawValue) {
return .iPad
} else if versionCode.contains("iPod") {
} else if code.contains(Type.iPod.rawValue) {
return .iPod
} else if versionCode == "i386" || versionCode == "x86_64" {
} else if code == "i386" || code == "x86_64" {
return .simulator
} else {
return .unknown
Expand Down
15 changes: 7 additions & 8 deletions Source/macOS/DeviceMacOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ public class Device {
}

static private func getType(code: String) -> Type {
let versionCode = Device.getVersionCode()
if versionCode.hasPrefix("MacPro") {
if code.hasPrefix("MacPro") {
return Type.macPro
} else if versionCode.hasPrefix("iMac") {
} else if code.hasPrefix("iMac") {
return Type.iMac
} else if versionCode.hasPrefix("MacBookPro") {
} else if code.hasPrefix("MacBookPro") {
return Type.macBookPro
} else if versionCode.hasPrefix("MacBookAir") {
} else if code.hasPrefix("MacBookAir") {
return Type.macBookAir
} else if versionCode.hasPrefix("MacBook") {
} else if code.hasPrefix("MacBook") {
return Type.macBook
} else if versionCode.hasPrefix("MacMini") {
} else if code.hasPrefix("MacMini") {
return Type.macMini
} else if versionCode.hasPrefix("Xserve") {
} else if code.hasPrefix("Xserve") {
return Type.xserve
}
return Type.unknown
Expand Down