From the course: iOS Development Tips

Unlock this course with a free trial

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

Enums

Enums

to get back to basics and this week, I'd like to review enums, which are a quick way of identifying data. If you download the exercise file, you'll find a slightly modified version of the doughnut menu we've been working with over the last few weeks. There were codes on either side of this itemNumber in the MenuEntry. But, I want to do this so that I don't have to go back and look at this. I want to actually be able to say this and that's what an enum is good for. And, you can see that I've already created two enums for you right here. The first one is for the DoughnutType and what I've done is you type enum to declare an enum. You declare a type, which, of course, that means this is going to be in the capital letter. And, I'm going to call this one DoughnutType and underneath that, you put the word case and then you give all the cases that are going to be here. And so, you have a finite number of cases that you have specifically noted. Here, I've got hole and I've got filled. And…

Contents