Using Codable with Array

I was converting one of my projects to Swift 4 and ran into an issue where I didn’t understand how to use the new Codable protocol to encode and decode an array of my model object. Here’s a little post explaining what I found out:

Repo: https://github.com/garricn/ggn-blog/tree/master/posts

Raw: https://raw.githubusercontent.com/garricn/ggn-blog/master/posts/060517-codable.swift

There’s also a playground in the repo.

Advertisements