Enum with Raw value, Codable
问题 The following code doesn't compile: enum Occupation: String { case designer = "Designer" case engineer = "Engineer" } public struct SteveJobs: Codable { let name: String let occupation: Occupation } On the other hand, it should compile since the Occupation is represented as a String which is Codable . Why can't I use enum with raw value in Codable structs? In particular, why automatic conformance isn't working in such a case. 回答1: Automatic Codable synthesis is “opt-in,” i.e. you have to