In most traditional object-oriented programming languages we create classes, which are reference types, as blueprints for our objects. In Swift, unlike other object-oriented languages, structures have much of the same functionality as classes; however, they are a value type. Apple has said that we should prefer value types, such as structures, to reference types, but what are the actual advantages? Swift actually has a number of type choices that we can use and, in this chapter, we will look at each of these types to see the advantages and disadvantages of each. Knowing how and when to use each type is important to properly implement protocol-oriented programming in your projects.
In this chapter, you will learn: