SimpleMDM-Swift Documentation

Structure Version

public struct Version: Codable, Comparable, LosslessStringConvertible  

A struct representing a "semantic versioning" version number.

While this struct tries to follow the SemVer 2.0.0 as close as possible, it takes some liberties for simplicity and convenience sake:

  • String version numbers omitting a "patch" component are accepted, and their patch component defaults to 0.

  • "Pre-release" version numbers (with an hyphen after the patch component) are currently not supported.

%79 Version Version Codable Codable Version->Codable Comparable Comparable Version->Comparable LosslessStringConvertible LosslessStringConvertible Version->LosslessStringConvertible

Conforms To

Codable
Comparable
LosslessStringConvertible

Initializers

init(major:​minor:​patch:​)

public init(major: Int, minor: Int, patch: Int)  

Memberwise initializer.

init?(_:​)

public init?(_ description: String)  

Instantiates a version number from a string representation.

The string will be parsed and the expected formats are either:

  • "MAJOR.MINOR", or

  • "MAJOR.MINOR.PATCH"

In the first case, the patch component of the version will default to 0.

If the parsed string is not in a valid format, the initializer will fail and return nil.

Parameters

value

The formatted version number.

init(from:​)

public init(from decoder: Decoder) throws  

Creates a new instance by decoding from the given decoder.

This initializer throws an error if reading from the decoder fails, or if the data if not in the expected version number format.

Parameters

decoder Decoder

The decoder to read data from.

Properties

description

public var description: String  

A textual representation of this version number.

Methods

encode(to:​)

public func encode(to encoder: Encoder) throws  

Encodes this value into the given encoder.

If the value fails to encode anything, encoder will encode an empty keyed container in its place.

This function throws an error if any values are invalid for the given encoder's format.

Parameters

encoder Encoder

The encoder to write data to.

Operators

<

public static func < (lhs: Version, rhs: Version) -> Bool  

Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.

A version number is considered less than another version number if any of its components, starting from major and ending with patch, is less than same component of the other version number.

Parameters

lhs Version

A value to compare.

rhs Version

Another value to compare.

==

public static func == (lhs: Version, rhs: Version) -> Bool  

Returns a Boolean value indicating whether two version numbers are equal.

Two version numbers are equal if all their components are equal.

Parameters

lhs Version

A value to compare.

rhs Version

Another value to compare.