NWDefault
public final class NWDefault
Provides strongly typed values associated with the lifetime of an application. Apropriate for user preferences.
Warning
Warning These should not be used to store sensitive information that could compromise the application or the user’s security and privacy.-
Shared instance of
Defaults, used for ad-hoc access to the user’s defaults database throughout the app.Declaration
Swift
public static let shared: NWDefault -
An instance of
Defaultswith the specifiedUserDefaultsinstance.Declaration
Swift
public init(userDefaults: UserDefaults = UserDefaults.standard)Parameters
userDefaultsThe UserDefaults.
-
Deletes the value associated with the specified key, if any.
Declaration
Swift
public func clear<ValueType>(_ key: Key<ValueType>) where ValueType : Decodable, ValueType : EncodableParameters
keyThe key.
-
Checks if there is a value associated with the specified key.
Declaration
Swift
public func has<ValueType>(_ key: Key<ValueType>) -> Bool where ValueType : Decodable, ValueType : EncodableParameters
keyThe key to look for.
Return Value
A boolean value indicating if a value exists for the specified key.
-
Returns the value associated with the specified key.
Declaration
Swift
public func get<ValueType>(for key: Key<ValueType>) -> ValueType? where ValueType : Decodable, ValueType : EncodableParameters
keyThe key.
Return Value
A
ValueTypeor nil if the key was not found. -
Sets a value associated with the specified key.
Declaration
Swift
public func set<ValueType>(_ value: ValueType, for key: Key<ValueType>) where ValueType : Decodable, ValueType : EncodableParameters
someThe value to set.
keyThe associated
Key<ValueType>. -
Removes given bundle’s persistent domain
Declaration
Swift
public func removeAll(bundle: Bundle = Bundle.main)Parameters
typeBundle.
-
Returns the value associated with the specified key.
Declaration
Swift
public func get<ValueType>(for key: Key<ValueType>) -> ValueType? where ValueType : Decodable, ValueType : Encodable, ValueType : RawRepresentable, ValueType.RawValue : Decodable, ValueType.RawValue : EncodableParameters
keyThe key.
Return Value
A
ValueTypeor nil if the key was not found. -
Sets a value associated with the specified key.
Declaration
Swift
public func set<ValueType>(_ value: ValueType, for key: Key<ValueType>) where ValueType : Decodable, ValueType : Encodable, ValueType : RawRepresentable, ValueType.RawValue : Decodable, ValueType.RawValue : EncodableParameters
someThe value to set.
keyThe associated
Key<ValueType>.
NWDefault Class Reference