O'Reilly logo

iOS 9 SDK Development by Janie Clayton, Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listing Possibilities with Enumerations

Structures are familiar to old C programmers, and they were available in Objective-C but were so limited that they were often ignored in favor of classes. Swift extensions tilt the balance back toward structs, as it does with another old C type: enumerations. The enum is a type that enumerates all its possible values. Its nice for times when you want to know there are a small number of valid values for something, like the suits of playing cards, positions in a team sport, and so forth.

Start a new playground called EnumsPlayground, and delete the "Hello playground" line. We’re going to use this playground to rethink our IOSDevice.

So far, whether class or struct, we’ve assumed our IOSDevice is a touchscreen ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required