'Can a Codable protocol be used for decoding without exposing the underlying type?
I want to do something like this where the underlying concrete types are not used, and instead only a Codable protocol is used.
protocol MyProtocol: Codable {}
struct MyProtocolImpl: MyProtocol {}
struct Something: Codable {
let x: MyProtocol
}
This does not compile with:
Type 'Something' does not conform to protocol 'Decodable'
I assume this is intentional by Swift, but I want to check whether I am missing something.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
