1 00:00:00,200 --> 00:00:01,540 So will come back again. 2 00:00:01,710 --> 00:00:06,600 Next thing that we have to address is something that is actually quite important for this particular 3 00:00:06,600 --> 00:00:07,300 game. 4 00:00:07,370 --> 00:00:13,610 Here is the situation that we have when we produce a new title and they give it the right Fauntleroy 5 00:00:13,620 --> 00:00:14,660 take size. 6 00:00:14,760 --> 00:00:20,620 And most importantly we give it the right title the right counter on it which is shown in here. 7 00:00:20,820 --> 00:00:27,210 We have to somehow have a mechanism where we can explore this value simply because later on in the game 8 00:00:27,240 --> 00:00:33,390 and I can click on tile like this one and then that one will have to be able to compare the values in 9 00:00:33,390 --> 00:00:38,810 them and make sure they are of the same type or the same value is present on both of them. 10 00:00:39,000 --> 00:00:44,050 Now you could simply assume that all we could actually read the value on the label. 11 00:00:44,100 --> 00:00:50,640 But I want to suggest a better solution and that is why subclassing the label to store this information 12 00:00:50,640 --> 00:00:52,130 summary internally. 13 00:00:52,260 --> 00:00:58,170 And the reason I want to do that is simply because you may not be only dealing with things such as labels 14 00:00:58,170 --> 00:01:00,160 that actually show their values. 15 00:01:00,210 --> 00:01:05,370 Maybe you would be working with something like a UI image that doesn't have a value that you can't read. 16 00:01:05,430 --> 00:01:09,740 So it's better if you actually have a subclass that can store this information. 17 00:01:09,900 --> 00:01:13,210 Now let me show you how we are going to do that in order to do it. 18 00:01:13,230 --> 00:01:19,380 I have to change some parts of my code and that's something I warned about at the beginning that one 19 00:01:19,380 --> 00:01:24,120 is that by the time we will be changing the code to get to where we want to get simply because that 20 00:01:24,120 --> 00:01:30,110 is how you work as a developer you don't really know everything right off the beginning as you go along. 21 00:01:30,210 --> 00:01:32,980 You will find different things that you have to do. 22 00:01:33,030 --> 00:01:37,610 So to do that I'm going to go in here and get myself and you file this one. 23 00:01:37,620 --> 00:01:40,430 I'm going to make it a subclass of you I Lavan. 24 00:01:40,440 --> 00:01:43,440 And I'm actually going to call it my label. 25 00:01:43,530 --> 00:01:51,200 So it's a subclass of a label in swift language of course and it is called My label and in my labor 26 00:01:51,440 --> 00:01:56,420 I'm going to go ahead and say I have a few prompters or a few attributes in here. 27 00:01:56,690 --> 00:02:03,950 One of them is something I'm going to call internal numbers and that's going to be an integer and that 28 00:02:03,980 --> 00:02:08,350 integer is going to be an optional explicitly wrap optional. 29 00:02:08,600 --> 00:02:14,640 And then I'm going to have to a static variable one of them is a static variable let's call it question. 30 00:02:14,900 --> 00:02:17,890 And that's going to be showing us a question mark. 31 00:02:18,170 --> 00:02:23,780 And the other one is going to be a static Larry again and I'm going to call this one a smile and I will 32 00:02:23,780 --> 00:02:27,250 show you why I'm adding these to in just a second. 33 00:02:27,290 --> 00:02:33,040 So this one is going to show me an emoji of a smart and if you're wondering on a macro machine you can 34 00:02:33,040 --> 00:02:37,820 press control command on the spacebar to get this emoji window. 35 00:02:38,060 --> 00:02:39,800 So I'm going to get that one. 36 00:02:39,870 --> 00:02:42,090 Now let's see why we have all of these. 37 00:02:42,170 --> 00:02:46,980 So the internal number is stores the value of the time. 38 00:02:47,080 --> 00:02:53,060 So that's quite easy to understand that we need to somehow restore the value and then later compare 39 00:02:53,060 --> 00:02:56,740 them against each other compare against the other. 40 00:02:56,750 --> 00:02:58,250 So that's about that. 41 00:02:58,250 --> 00:03:03,950 Now I know in my iPad simulator right now we can see all the numbers but obviously that's not how the 42 00:03:03,950 --> 00:03:05,260 game is going to be played. 43 00:03:05,330 --> 00:03:08,620 The game will be played by all of these tiles to be flipped. 44 00:03:08,780 --> 00:03:11,940 And as they are flipped I want to see a question mark on them. 45 00:03:12,080 --> 00:03:15,100 So the user has to guess what's the number behind them. 46 00:03:15,260 --> 00:03:21,170 So that is going to be the default presentation of all tiles. 47 00:03:21,260 --> 00:03:28,320 And finally if I tapped on two similar tiles and I found them I want to be able to see this one. 48 00:03:28,340 --> 00:03:34,900 So smile is the final result when we match times. 49 00:03:35,120 --> 00:03:36,800 So that's about it. 50 00:03:36,800 --> 00:03:42,080 Now let me take you back to the very original design of the RPG after they have actually developed before 51 00:03:42,110 --> 00:03:43,890 and show you that in practice. 52 00:03:43,910 --> 00:03:46,510 So when the app launches we see all the question marks. 53 00:03:46,520 --> 00:03:52,670 If we tap on any two of them we see the internal number and I got lucky and I got most of them to show 54 00:03:52,670 --> 00:03:56,350 me the slides Let me show you another one so the entire number is zero. 55 00:03:56,480 --> 00:03:59,570 The other number is two and they all flip back to question marks. 56 00:03:59,690 --> 00:04:05,390 And if I find another one of the zero or two I can actually match them against each other three and 57 00:04:05,390 --> 00:04:06,120 four. 58 00:04:06,290 --> 00:04:07,530 And that is three and three. 59 00:04:07,550 --> 00:04:10,030 And if we find them I want to see a little smile. 60 00:04:10,190 --> 00:04:13,850 Guess where I have the internal number to remember what number I need. 61 00:04:13,910 --> 00:04:19,900 The question was to show by the fourth and the smile to show in case I found something. 62 00:04:19,910 --> 00:04:23,280 Now we have this cause obviously we haven't used it anywhere. 63 00:04:23,300 --> 00:04:25,870 So let's go ahead and use it in our actual code. 64 00:04:25,890 --> 00:04:27,470 And then what of your controller. 65 00:04:27,600 --> 00:04:28,510 I didn't hear. 66 00:04:28,640 --> 00:04:33,860 I'm going to go ahead and see where I'm going to make the toilets instead of them making tiles of the 67 00:04:33,860 --> 00:04:35,570 type I label. 68 00:04:35,630 --> 00:04:38,670 I'm actually going to make them by my label type. 69 00:04:38,810 --> 00:04:45,710 I'm using my leave it is going to be identical to using a label simply because my left label is a subclass 70 00:04:45,710 --> 00:04:47,000 of you I label. 71 00:04:47,070 --> 00:04:52,850 And because of that I can still use it in its fifth frame and I can actually use the font text and I 72 00:04:52,860 --> 00:05:00,000 mean almost everything stays intact except for one thing and that is all I have to store the value that 73 00:05:00,000 --> 00:05:05,170 they show on each of them inside a property called internal number. 74 00:05:05,180 --> 00:05:12,050 So I'm going to go in here and say you are going to show this slide your counter on every tide and that 75 00:05:12,050 --> 00:05:14,100 is the number we need to store. 76 00:05:14,270 --> 00:05:20,820 So I'm going to go ahead and say Hi Dot internal number becomes counter. 77 00:05:21,050 --> 00:05:24,430 So we store the value and then of course we show it there. 78 00:05:24,500 --> 00:05:29,240 You could either show counter again or if you wanted to you could actually show the tiles that internal 79 00:05:29,240 --> 00:05:32,860 number and since entire number is an optional value. 80 00:05:32,930 --> 00:05:36,080 I have to make sure that I explicitly wrap it. 81 00:05:36,200 --> 00:05:41,390 So I'll wrap it to show me the actual value and if I run the application we should be able to see the 82 00:05:41,390 --> 00:05:47,850 exact same thing as if you had before but now we have a little bit of more confidence as to what's happening. 83 00:05:47,870 --> 00:05:55,810 For instance this tile number five it is showing 5 and some internally it is storing the value of 5. 84 00:05:55,970 --> 00:06:00,640 So that is really going to help us in the future upcoming things that we have to do. 85 00:06:00,860 --> 00:06:02,450 So just keep it up to here. 86 00:06:02,510 --> 00:06:10,020 In this is and we added the my label class and we use the my label class to populate our titles and 87 00:06:10,020 --> 00:06:11,570 let's move on to our next lesson.