[swift-users] Where CodingKey protocol is implemented on swift source code

Solli Honorio shonorio at gmail.com
Wed Oct 4 17:38:49 CDT 2017


Thanks for the clarification.

Em qua, 4 de out de 2017 às 19:21, Itai Ferber <iferber at apple.com> escreveu:

> Hi Solli,
>
> CodingKey conformance for enums is synthesized by the compiler given
> certain rules — you can see mention of this in the Codable proposal
> <https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md>
> [search for public protocol CodingKey].
> If you’re interested in specific implementation for how the compiler does
> this, you can refer to lib/Sema/DerivedConformanceCodingKey.cpp
> <https://github.com/apple/swift/blob/master/lib/Sema/DerivedConformanceCodingKey.cpp>
> .
>
> Happy to answer any questions on this you might have.
>
> — Itai
>
> On 4 Oct 2017, at 14:50, Solli Honorio via swift-users wrote:
>
> Studying "Codable.swift" and "JSONEncoder.swift" to understand how decoding
> works under the hood, I got confused about how CodingKey is implemented for
> 'enum'. Shouldn't have an extension of RawRepresentable to implement the
> CodingKey protocol?
>
> This is the answer I'm looking for, how the CodingKey protocol is
> implemented on enum?
>
> I appreciate any help, tks
>
> Solli Honorio
>
> --
> "o animal satisfeito dorme". - Guimarães Rosa
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
> --
Enviado do Gmail para celular
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171004/0f4d68a0/attachment.html>


More information about the swift-users mailing list