0
1
00:00:01,100 --> 00:00:06,660
All right, guys, in this module, we're going to be talking about Advanced Swift Properties.
1

2
00:00:06,690 --> 00:00:09,950
Now, previously, we've already seen what properties are
2

3
00:00:09,960 --> 00:00:16,560
and we've been using it throughout the course. Now, when we looked at objects and classes, we learned that
3

4
00:00:16,560 --> 00:00:25,470
properties can be a constant or it can be a variable, and they allow us to store data relating to a particular
4

5
00:00:25,500 --> 00:00:27,230
object or a class.
5

6
00:00:27,240 --> 00:00:34,620
So, for example, in this case, we've got a car object that has a color property that's equal to red and
6

7
00:00:34,650 --> 00:00:37,760
a type property that's equal to "coupe."
7

8
00:00:37,800 --> 00:00:42,140
It doesn't matter if it's a constant or variable, they're both properties.
8

9
00:00:42,180 --> 00:00:49,890
Now, more specifically, these types of properties can be described as stored properties because, essentially,
9

10
00:00:50,170 --> 00:00:56,400
they're just a container that can take a value and you could store it inside the container.
10

11
00:00:56,610 --> 00:01:02,390
And when you later need to use this stored property, you can take out the value and use it.
11

12
00:01:02,670 --> 00:01:08,970
Now, in this lesson and others in the module, we're going to be talking about a different type of property,
12

13
00:01:09,180 --> 00:01:11,860
and these are called computed properties.
13

14
00:01:12,300 --> 00:01:21,030
And what these allow us to do is to create properties whose values can be calculated on the go by using
14

15
00:01:21,060 --> 00:01:27,090
the code that we write and that will make it really similar to an Excel spreadsheet.
15

16
00:01:27,090 --> 00:01:34,620
So for example, if we were trying to work out the area of a particular wall, say, in our bathroom, and we
16

17
00:01:34,620 --> 00:01:43,250
actually recorded it wrong, instead of being 1.5 by 2.6 meters, actually, that wall height was 2.3 meters.
17

18
00:01:43,470 --> 00:01:51,690
Well, then in that case, the area can auto-update and be calculated or computed based off the change in
18

19
00:01:51,690 --> 00:01:52,720
the height,
19

20
00:01:52,770 --> 00:01:58,350
and this is exactly what we're going to do with our code. And the code that we're going to write is going
20

21
00:01:58,350 --> 00:02:05,640
to be super useful because we're going to use it to solve the biggest issue that mankind has which is,
21

22
00:02:05,640 --> 00:02:11,610
of course, how many pizzas should you buy, so that you can feed everybody who's in your house.
22

23
00:02:11,610 --> 00:02:15,050
This has mystified mankind for a long time.
23

24
00:02:15,060 --> 00:02:20,380
And finally, we're going to be able to use computed properties to solve this problem.
24

25
00:02:20,430 --> 00:02:24,930
So once you're ready, head over to the next lesson and we'll get started right away.
