Commit 48fb719d by Sarkizz

添加系统版本获取逻辑

parent 946f0bc0
......@@ -9,6 +9,58 @@
import Foundation
import KeychainAccess
/// 系统版本号封装
public struct MRSystemVersion {
private var version: String
public var string: String {
return version
}
init(version: String) {
self.version = version
}
}
extension MRSystemVersion: Equatable {
public static func == (lhs: MRSystemVersion, rhs: MRSystemVersion) -> Bool {
return lhs.version == rhs.version
}
}
extension MRSystemVersion: MRCompareToString {
public static func == (lhs: MRSystemVersion, rhs: String) -> Bool {
return lhs.version == rhs
}
public static func < (lhs: MRSystemVersion, rhs: MRSystemVersion) -> Bool {
return lhs.compare(with: rhs.version) == .orderedSame
}
public static func >= (lhs: MRSystemVersion, rhs: String) -> Bool {
let rs = lhs.compare(with: rhs)
return rs == .orderedSame || rs == .orderedDescending
}
public static func > (lhs: MRSystemVersion, rhs: String) -> Bool {
return lhs.compare(with: rhs) == .orderedDescending
}
public static func <= (lhs: MRSystemVersion, rhs: String) -> Bool {
let rs = lhs.compare(with: rhs)
return rs == .orderedSame || rs == .orderedAscending
}
public static func < (lhs: MRSystemVersion, rhs: String) -> Bool {
return lhs.compare(with: rhs) == .orderedAscending
}
public func compare(with string: String) -> ComparisonResult {
return self.version.compare(string)
}
}
/// 设备信息
public final class MRDevice {
......@@ -19,6 +71,11 @@ public final class MRDevice {
return UIDevice.current.modelVersion
}
/// 系统版本号
public class var systemVersion: MRSystemVersion {
return MRSystemVersion(version: UIDevice.current.systemVersion)
}
/// App的版本号
public class var appShortVersion: String? {
return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment