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 Defaults with the specified UserDefaults instance.

    Declaration

    Swift

    public init(userDefaults: UserDefaults = UserDefaults.standard)

    Parameters

    userDefaults

    The UserDefaults.

  • Deletes the value associated with the specified key, if any.

    Declaration

    Swift

    public func clear<ValueType>(_ key: Key<ValueType>) where ValueType : Decodable, ValueType : Encodable

    Parameters

    key

    The 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 : Encodable

    Parameters

    key

    The 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 : Encodable

    Parameters

    key

    The key.

    Return Value

    A ValueType or 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

    Parameters

    some

    The value to set.

    key

    The associated Key<ValueType>.

  • Removes given bundle’s persistent domain

    Declaration

    Swift

    public func removeAll(bundle: Bundle = Bundle.main)

    Parameters

    type

    Bundle.

ValueType with RawRepresentable conformance

  • 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 : Encodable

    Parameters

    key

    The key.

    Return Value

    A ValueType or 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 : Encodable

    Parameters

    some

    The value to set.

    key

    The associated Key<ValueType>.