<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">Hi Solli,</p>
<p dir="auto"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">CodingKey</code> conformance for <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">enum</code>s is synthesized by the compiler given certain rules — you can see mention of this in the <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md" style="color:#3983C4">Codable proposal</a> [search for <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">public protocol CodingKey</code>].<br>
If you’re interested in specific implementation for how the compiler does this, you can refer to <a href="https://github.com/apple/swift/blob/master/lib/Sema/DerivedConformanceCodingKey.cpp" style="color:#3983C4">lib/Sema/DerivedConformanceCodingKey.cpp</a>.</p>
<p dir="auto">Happy to answer any questions on this you might have.</p>
<p dir="auto">— Itai</p>
<p dir="auto">On 4 Oct 2017, at 14:50, Solli Honorio via swift-users wrote:</p>
<p dir="auto"></p></div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">Studying "Codable.swift" and "JSONEncoder.swift" to understand how decoding<br>
works under the hood, I got confused about how CodingKey is implemented for<br>
'enum'. Shouldn't have an extension of RawRepresentable to implement the<br>
CodingKey protocol?<br>
<br>
This is the answer I'm looking for, how the CodingKey protocol is<br>
implemented on enum?<br>
<br>
I appreciate any help, tks<br>
<br>
Solli Honorio<br>
<br>
-- <br>
"o animal satisfeito dorme". - Guimarães Rosa<br>
_______________________________________________<br>
swift-users mailing list<br>
swift-users@swift.org<br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" style="color:#777">https://lists.swift.org/mailman/listinfo/swift-users</a></p>
</blockquote></div>
<div style="white-space:normal">
</div>
</div>
</body>
</html>