Mastering the Building Blocks
The previous chapter explained the basic types that form the building blocks of the Swift language. In this chapter, we will build on this knowledge to create more complex structures, such as arrays and dictionaries, before moving on and looking at some of the little gems Swift offers, such as tuples and type aliases. Finally, we’ll round off this chapter by looking at extensions and access control – both of which are key components that contribute to a sound yet efficient code base.
By the end of this chapter, you will be better equipped to organize and handle any data you’ll want to work with in your apps, plus the ability to make the code that interacts with your data more flexible to your needs!
In this chapter, we will cover the following recipes:
- Bundling variables into tuples
- Ordering your data with arrays
- Containing your data in sets
- Storing key-value pairs with dictionaries
- Subscripts for custom types
- Changing your name with a type alias
- Getting property-changing notifications using property observers
- Extending functionality with extensions
- Controlling access with access control
Let’s get started!