UserDefaultsSerializable

public protocol UserDefaultsSerializable

Describes a value that can be saved to and fetched from UserDefaults.

Default conformances are provided for:

  • Bool
  • Int
  • UInt
  • Float
  • Double
  • String
  • URL
  • Date
  • Data
  • Array
  • Set
  • Dictionary
  • RawRepresentable types
  • Codable types
  • The type of the value that is stored in UserDefaults.

    Declaration

    Swift

    associatedtype StoredValue
  • The value to store in UserDefaults.

    Declaration

    Swift

    var storedValue: StoredValue { get }
  • Initializes the object using the provided value, or returns nil if initialization fails.

    Declaration

    Swift

    init?(storedValue: StoredValue)

    Parameters

    storedValue

    The previously store value fetched from UserDefaults.