Created
March 18, 2022 22:04
-
-
Save thanakijwanavit/1100d1d0efad5d9ae82682aaf3028950 to your computer and use it in GitHub Desktop.
swift enum extension for making it comply with codable and default type
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 Type: Codable { | |
public init(from decoder: Decoder) throws { | |
self = try Type(rawValue: decoder.singleValueContainer().decode(RawValue.self)) ?? .unknown | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment