FoilDefaultStorageOptional

@propertyWrapper
public struct FoilDefaultStorageOptional<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 retrieved 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.