AppSettingsReader

public protocol AppSettingsReader: class

Entities conforming to this protocol are capable of providing values for application settings.

Application settings are global values available to the application at runtime. Settings values should persist across application launches, and should be available locally on the device running the application.

Storage for application settings is typically provided by the operating system and may be transparently synchronized across multiple devices depending on the underlying implementation.

This framework also extends UserDefaults, allowing it to be used as an AppSettingsReader.

  • Returns the names of the application settings for which values currently exist.

    Declaration

    Swift

    var settingNames: [String]

    Return Value

    The application settings names.

  • Returns the value of the setting with the specified name.

    Declaration

    Swift

    func value(named name: String) -> Any?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting, or nil if no such setting exists.

  • value(named:default:) Default implementation

    Returns the value of the setting with the specified name.

    Default Implementation

    Returns the value of the setting with the specified name.

    Declaration

    Swift

    func value(named name: String, default defaultValue: Any) -> Any

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting.

  • bool(named:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a boolean value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a boolean value.

    Declaration

    Swift

    func bool(named name: String) -> Bool?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting. Will be nil if there is no value for the setting, or if the value couldn’t be interpreted as a Bool.

  • bool(named:default:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a boolean value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a boolean value.

    Declaration

    Swift

    func bool(named name: String, default defaultValue: Bool) -> Bool

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value of the correct type for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting that can be interpreted as a Bool.

  • number(named:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a numeric value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a numeric value.

    Declaration

    Swift

    func number(named name: String) -> NSNumber?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting. Will be nil if there is no value for the setting, or if the value couldn’t be interpreted as an NSNumber.

  • number(named:default:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a numeric value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a numeric value.

    Declaration

    Swift

    func number(named name: String, default defaultValue: NSNumber) -> NSNumber

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value of the correct type for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting that can be interpreted as an NSNumber.

  • int(named:) Default implementation

    Returns the value of the setting with the specified name, interpreted as an integer value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as an integer value.

    Declaration

    Swift

    func int(named name: String) -> Int?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting. Will be nil if there is no value for the setting, or if the value couldn’t be interpreted as an Int.

  • int(named:default:) Default implementation

    Returns the value of the setting with the specified name, interpreted as an integer value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as an integer value.

    Declaration

    Swift

    func int(named name: String, default defaultValue: Int) -> Int

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value of the correct type for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting that can be interpreted as an Int.

  • double(named:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a floating-point value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a floating-point value.

    Declaration

    Swift

    func double(named name: String) -> Double?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting. Will be nil if there is no value for the setting, or if the value couldn’t be interpreted as a Double.

  • double(named:default:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a floating-point value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a floating-point value.

    Declaration

    Swift

    func double(named name: String, default defaultValue: Double) -> Double

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value of the correct type for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting that can be interpreted as a Double.

  • string(named:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a string value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a string value.

    Declaration

    Swift

    func string(named name: String) -> String?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting. Will be nil if there is no value for the setting, or if the value couldn’t be interpreted as a String.

  • string(named:default:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a string value.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a string value.

    Declaration

    Swift

    func string(named name: String, default defaultValue: String) -> String

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value of the correct type for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting that can be interpreted as a String.

  • array(named:) Default implementation

    Returns the value of the setting with the specified name, interpreted as an array.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as an array of Any.

    Declaration

    Swift

    func array(named name: String) -> [Any]?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting. Will be nil if there is no value for the setting, or if the value couldn’t be interpreted as an array of Any.

  • array(named:default:) Default implementation

    Returns the value of the setting with the specified name, interpreted as an array of Any.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as an array of Any.

    Declaration

    Swift

    func array(named name: String, default defaultValue: [Any]) -> [Any]

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value of the correct type for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting that can be interpreted as an array of Any.

  • dictionary(named:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a dictionary.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a a [String: Any] dictionary.

    Declaration

    Swift

    func dictionary(named name: String) -> [String: Any]?

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    Return Value

    The value of the setting. Will be nil if there is no value for the setting, or if the value couldn’t be interpreted as an NSDictionary.

  • dictionary(named:default:) Default implementation

    Returns the value of the setting with the specified name, interpreted as a dictionary.

    Default Implementation

    Returns the value of the setting with the specified name, interpreted as a a [String: Any] dictionary.

    Declaration

    Swift

    func dictionary(named name: String, default defaultValue: [String: Any]) -> [String: Any]

    Parameters

    name

    The name of the setting whose value is to be retrieved.

    defaultValue

    A default value to use in case there is no existing value of the correct type for the given setting.

    Return Value

    The value of the setting, or defaultValue if there is currently no value for the specified setting that can be interpreted as an NSDictionary.