From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,700 courses taught by industry experts.

Changes to enums in Swift

Changes to enums in Swift

- [Instructor] There's a protocol now available to enums that were available to other types. You can now compare values. Let's look at how the comparable protocol works with enum. If you've downloaded the exercise files you will find the previous tip's code and we're going to make another change to this. If you remember from last time, I had in here in cocoa, I had, if temp == .roomTemp or temp == .cold. Now that's great, if you go back up to the code here you only have got two cases where this is going to be true, but suppose you have a whole bunch of cases. For example, you've got some status issues for a type and some of them are errors and some of them are not. You put all the errors first and then all the nots second. And you want to be able to say that the ones up here are one thing, and the ones down here are another, and be nice to use like a less than, or less than equal to here. And so you can start to do…

Contents