November 2016
Intermediate to advanced
480 pages
14h 42m
English
Up to this point, you have been using the built-in types that Swift provides, like integers, strings, arrays, and dictionaries. The next couple of chapters will show the capabilities the language provides to create your own types. The focus of this chapter is enumerations (or enums), which allow you to create instances that are one of a defined list of cases. If you have used enumerations in other languages, much of this chapter will be familiar. But Swift’s enums also have some advanced features that make them unique.
Create a new playground called Enumerations. Define an enumeration of possible text alignments.
Listing 14.1 Defining an enumeration
import Cocoavar str = "Hello, ...
Read now
Unlock full access