Last active
August 17, 2021 01:27
-
-
Save iwill/fd14a420b0d116004df5ff9189f29b7e to your computer and use it in GitHub Desktop.
Code Snippet: Adopte to ExCodable protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#extension/struct/class#> <#Type#>: ExCodable { | |
static let <#keyMapping#>: [KeyMap<<#SelfType#>>] = [ | |
KeyMap(\.<#property#>, to: <#"key"#>), | |
<#...#> | |
] | |
init(from decoder: Decoder) throws { | |
try decode<#Reference#>(from: decoder, with: Self.<#keyMapping#>) | |
} | |
func encode(to encoder: Encoder) throws { | |
try encode(to: encoder, with: Self.<#keyMapping#>) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ExCodable: https://github.com/iwill/ExCodable