Key

public enum Key<T>: CustomStringConvertible

Mechanica

Base enum for static keys with a phantom type. Specialize this enum with a type and initialize it with a key, key path (both namespaced or not). - Note: Use Key to avoid stringly typed APIs.

  • simple: a String key or key path.
  • namespaced: a namespaced String key or key path.
Key<String>("myKey1") // value: myKey1
Key<Int>("myKey2", namespace: "org.tinrobots")  // value: org.tinrobots.myKey2
Key<Bool>("myKey2", namespace: "org.tinrobots") // value: org.tinrobots.myKey3
  • Mechanica

    A simple String key, use it for no namespaced keys or key paths.

    Declaration

    Swift

    case simple(String)
  • Mechanica

    A namespaced String key.

    Declaration

    Swift

    case namespaced(String, namespace: String)
  • Create a new Key.

    Declaration

    Swift

    public init(_ string: String, namespace: String? = nil)

    Parameters

    string

    key or key path value.

    namespace

    optional namespace for the key to avoid collision with other keys with the same value defined in other libraries.

  • Mechanica

    Returns the key formatted with the namespace if defined.

    Declaration

    Swift

    public var value: String
  • Mechanica

    Returns the key formatted with the namespace if defined.

    Declaration

    Swift

    public var description: String