ConfigurationSwitcher
public class ConfigurationSwitcher
ConfigurationSwitcher
is a singleton that allows for environment/configuration switching when working with staging/production environments. Selections are persistent across sessions and can be updated on the fly.
-
Getter/Setter for the current
ServerConfiguration
identity. When setting this value it will write toUserDefaults
using thedefaultsKey
value as the key.Complexity
O(1)
Declaration
Swift
public var configuration: String { get set }
Return Value
A string value representing the indetity of the currently selected
ServerConfiguration
-
Getter for the current
ServerConfiguration
environment variables.Complexity
O(1)
Declaration
Swift
public var environmentVariables: [String : String] { get }
Return Value
A dictionary value representing the identity of the currently selected
ServerConfiguration
-
Setter for a given
ServerConfiguration
object. Must use this setter asConfigurationSwitcher.init()
is markedinternal
for API purposes. Calling this function will remove all duplicateServerConfiguration
objects based on theidentifier
that is passed in.Complexity
O(n) where n is the number of
ServerConfiguration
objects inside theconfigurations
array that have theidentifier
Declaration
Swift
public func configureEnvironment(withIdentifier identifier: String, variables: [String : String] = [:])
Parameters
identifier
The name of the environment that the caller is attempting to set the value of.
variables
The dictionary that the caller/client’s application has configured for this environment.