Marina Sauca

8 min read

Apr 10, 2020

Press enter or click to view image in full size

Photo by Maxwell Nelson on Unsplash

Codable and Generics are my favourite part of the Swift language, they are pretty, simple and very very powerful!

If you do not know about them, I sincerely encourage you to play around with them! You can find detailed information about Generics here and about Codable here.

Picture this: you are having a marvellous day and suddenly you are told to implement an API in your app. No big deal uh? Anybody can do that! lemme add the pod for Alamo… no, we’re not going that route, we are going to implement everything ourselves!

Why? Well, that’s a fair question. First of all, I do not endorse adding a library if, given time, you wouldn't know how to do that yourself. So, just for the sake of learning, it’s already a good idea.

Secondly, API libraries are behemoths, they have tons and tons and tons of functionalities that you may not need, they make your app weight more and they add something in the middle of your code and the server (hey, I trust them, but you can't deny the fact that you are relinquishing control).

Still onboard? Good, let’s make some noise.

Before levelling up our game with Combine, though, allow me to explain everything in plain old Swift. For the examples I will use a free cat facts API…