Created
July 29, 2023 13:05
-
-
Save foxicode/0a9c8c5cfe2efe0919e20e78161c8562 to your computer and use it in GitHub Desktop.
Encodable copyCodable Swift extension
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
| public extension Encodable where Self: Decodable { | |
| func copyCodable() throws -> Self { | |
| let data = try JSONEncoder().encode(self) | |
| return try JSONDecoder().decode(Self.self, from: data) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment