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 implementationReturns 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 implementationReturns 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 aBool
. -
bool(named:default:)
Default implementationReturns 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 aBool
. -
number(named:)
Default implementationReturns 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 anNSNumber
. -
number(named:default:)
Default implementationReturns 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 anNSNumber
. -
int(named:)
Default implementationReturns 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 anInt
. -
int(named:default:)
Default implementationReturns 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 anInt
. -
double(named:)
Default implementationReturns 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 aDouble
. -
double(named:default:)
Default implementationReturns 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 aDouble
. -
string(named:)
Default implementationReturns 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 aString
. -
string(named:default:)
Default implementationReturns 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 aString
. -
array(named:)
Default implementationReturns 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 ofAny
. -
array(named:default:)
Default implementationReturns 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 ofAny
. -
dictionary(named:)
Default implementationReturns 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 anNSDictionary
. -
dictionary(named:default:)
Default implementationReturns 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 anNSDictionary
.