CodableUserDefault
@propertyWrapper
public struct CodableUserDefault<Key, Value> where Key : RawRepresentable, Value : Decodable, Value : Encodable, Key.RawValue == String
Usage notes: CodableUserDefault
PlistUserDefault supports plist-compatible types: Data, String, Number, Date, Array and Dictionary.
CodableUserDefault supports any type conforming to the Codable protocol (which includes plist-compatible types, but also structs and enums conforming to Codable.
Note: PlistUserDefault must be used for settings declared in Settings.bundle/Root.plist (because these are stored in type-specific formats, while CodableUserDefault stores/retrieves all types as Data).
-
Declaration
Swift
let key: Key
-
Declaration
Swift
let defaultValue: Value
-
Declaration
Swift
public init(key: Key, defaultValue: Value, userDefaults: UserDefaults = UserDefaults.standard)
-
Declaration
Swift
public var wrappedValue: Value { get set }