What you'll learn
- Value Types
- Reference Types
Complex Data Structures
We're going to try our hand at modeling a simple tower defense game. The simples data point that we need to model is a Point and in the first set of videos, we'll look at how a structure makes it really easy to model a coordinate point. We'll look at creating instances of points using this blueprint as well as writing methods to work on the data stored in an instance.
Now that we have a Point struct to represent a coordinate point we can focus on the rest of the game. The next object we're going to use is called a class. Much like a struct, a class lets us model a custom data type, with some subtle differences. In the next set of videos we look at how to create a class and get some more practice in working with objects.
So far we've seen two types of objects that Swift offers but we don't really know the difference between the two. While structs allow us to model simple values, classes allow us to create families of related objects. Over the next few videos, we'll look at how we can inherit from other classes and modify their properties and behaviors to suit our needs.
Differentiating Between Objects
We touched on a major way that structs and classes differ - inheritance. But there are other more subtle ways we can distinguish between the two and in this stage we take a look at how and why it matters.