From the course: iOS App Development: RESTful Web Services

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Enumerations and Codable

Enumerations and Codable - iOS Tutorial

From the course: iOS App Development: RESTful Web Services

Start my 1-month free trial

Enumerations and Codable

- [Narrator] Now we know from learning Swift that enumerations can do more than just represent values. They can also have other underlying types. They can have associated values. They can have functions. And they can also implement Codable. One of the easiest ways to make this happen is for it to have a base type that implements Codable, such as string or end. So, let's look at how we can do that in our code. So looking at the data that's passed back from the server, we can see we have a variety of things that are set. Not all of them would map directly to something that would work as an enumeration, but I'm going to choose to use this created_by, and I'm going to make sure that of course that this created_by value exists in our enumeration. So, I'll copy it. We're going to specify an enumeration for the creator of different music, and then as it's set, by parsing it from the data passed from the server, it will use our enumeration now. So, I'm going to go back up to the top of our…

Contents