|
im on day 49 and when i was reading the second article i saw decoder.container which i didnt understand. Heres the full code
also i saw it on encoder aswell but i presume its the same as decoder, so ill understand once someone explains me the regular one. Also i seem to be a bit lost on the whole Codable/ data saving learning part. I grasp everything else very well but that. is there any article i could read. that would re-teach me. the same(or similar) things? or should i just re read the regular hws articles? |
|
A A keyed container is a dictionary. It contains values that are referenced by keys.
An unkeyed container is an array. It contains a list of values that can be accessed by index.
Keyed and unkeyed containers can be combined in an individual JSON file. The code
is indicating that you are trying to extract a keyed container (i.e., a dictionary) from some JSON and that the keys used in that dictionary correspond to the |
|
You could always try reading apple's documentation to see if it helps solidify some things. However, I usually find Paul's approches to be much easier to read and digest. If you look at the documentation for the Then, if you look at the documentation for the
I'm not sure if you have reached the part in the course that covers Type Generics yet. But this basically says that the So, in your example...
we are giving it The
So, when you call the That's why we have to use this afterward...
That basically says, "Take all those ones and zeroes stored in the |
|
Just realized I forgot the third kind of So, to sum up:
And, technically, every If your Something I have found most helpful is the Flight School Guide to Swift Codable, which used to cost but is now available for free download. (The sample JSON I annotated above comes from that book, in fact.) It contains numerous examples of |
|
|
|
|
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.