Skip to content

用法问题 #3

@CoderLouie

Description

@CoderLouie

比如这样一个模型

struct Coord: ExCodable {
    private(set) var y: Int = 0
    private(set) var x: Int = 0
    private(set) var w: Int = 0
    private(set) var h: Int = 0
    
    static var keyMapping: [KeyMap<Coord>] {
        [KeyMap(\.y, to: "y")]
    }
    init(from decoder: Decoder) throws {
        try decode(from: decoder, with: Self.keyMapping)
    }
}
static var keyMapping: [KeyMap<Coord>] {
      [KeyMap(\.y, to: "y"),
       ....
      ]
}

我需要在这个方法中把所有的属性都列出来吗?可能做到 只列出那些需要做映射的属性,不用做映射的属性可以不列出

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions