Dictionary

  • Instantiates a Dictionary<Key, Value> from an environment variable string representation where the Key and Value conform to EnvironmentStringConvertible.

    Elements must be comma (,) separated and key/value pairs must be colon (:) separated in the string representation.

    let numbers = [String : Int](environmentString: "one:1,two:2,three:3")
    print(numbers)
    // Prints "Optional(["one": 1, "three": 3, "two": 2])"
    

    This enables setting and getting a dictionary using the Environment.

    Environment.environment.NUMBERS = ["one":1,"two":2,"three":3]
    // Sets a string value of "one:1,two:2,three:3"
    
    let numbers: [String : Int]? = Environment.environment.NUMBERS
    // Gets a dictionary of ["one":1,"two":2,"three":3]
    

    Declaration

    Swift

    public init?(environmentString: String)

    Parameters

    environmentString

    The string representation of the environment variable.

  • The environment variable string representation.

    Elements are comma (,) separated and key/value pairs are colon (:) separated.

    let numbers = ["one": 1, "two": 2, "three": 3]
    print(numbers.environmentString)
    // Prints "one:1,two:2,three:3"
    

    Declaration

    Swift

    public var environmentString: String { get }