WrappedDefaultOptional

@propertyWrapper
public struct WrappedDefaultOptional<T> where T : UserDefaultsSerializable

A property wrapper that uses UserDefaults as a backing store, whose wrappedValue is optional and does not provide default value.

  • key

    The key for the value in UserDefaults.

    Declaration

    Swift

    public let key: String
  • The value retreived from UserDefaults, if any exists.

    Declaration

    Swift

    public var wrappedValue: T? { get set }
  • A publisher that delivers updates to subscribers.

    Declaration

    Swift

    public var projectedValue: AnyPublisher<T?, Never> { get }
  • Initializes the property wrapper.

    Declaration

    Swift

    public init(key keyName: String, userDefaults: UserDefaults = .standard)

    Parameters

    keyName

    The key for the value in UserDefaults.

    userDefaults

    The UserDefaults backing store. The default value is .standard.