VersionHelper
public class VersionHelper
VersionHelper compares the version of the app. The version should be as the format of 1.2.3 where the first number will be changed if the style of the application is changed, the second number will be changed if some main functions are changed and the third number will be changed whenever errors or functions are fixed or changed.
Version
1.5.0Date
23/03/2019-
The shared helper that presents current version. It will be nil if the version cannot be retrieved.
Declaration
Swift
public static let standard: VersionHelper?
-
Return the grand version number.
Declaration
Swift
public var grandVersion: Int? { get }
-
Whether current version flag has been settled in the user default or not.
Declaration
Swift
public var hasVersionFlag: Bool { get }
-
Compare current version to the given version.
Declaration
Swift
public func compareCurrentVersion(toVersion version: String) -> Int?
Parameters
version
The given version.
Return Value
1 if current version is larger. 0 if current version equals the given version. -1 if current version is smaller. nil if there has been an error. Nil will be returned if one of the versions is not formatted.
-
Create current version flag in the user default, indicating that current version has been opened once.
Declaration
Swift
public func createVersionFlag()
-
Delete current version flag in the user default.
Declaration
Swift
public func deleteVersionFlag()
-
Initialize the helper.
Declaration
Swift
public init?(version: String, versionFlag: String, userDefaults: UserDefaults = .standard)
Parameters
version
The version binded to the helper.
versionFlag
The flag used to identify whether the version has been launched before or not.
userDefaults
The UserDefaults used to store the flag.