SwiftyUserDefaults icon indicating copy to clipboard operation
SwiftyUserDefaults copied to clipboard

How to support [key:value] type with value:Codable,DefaultsSerializable

Open yanxiaobing opened this issue 3 years ago • 0 comments

struct TestM: Codable,DefaultsSerializable{
    var name: String?
    var age: Int? = 0
}

extension DefaultsKeys{
    var tests: DefaultsKey<[String:[TestM]]>{.init("tests", defaultValue: [String:[TestM]]())}
}

let testM = TestM.init(name: "test", age: 18)
Defaults[\.tests]["tests"] = [testM]

yanxiaobing avatar Jun 14 '22 07:06 yanxiaobing