Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Created March 18, 2022 22:04
Show Gist options
  • Save thanakijwanavit/1100d1d0efad5d9ae82682aaf3028950 to your computer and use it in GitHub Desktop.
Save thanakijwanavit/1100d1d0efad5d9ae82682aaf3028950 to your computer and use it in GitHub Desktop.
swift enum extension for making it comply with codable and default type
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