So will come back again.
Next thing that we have to address is something that is actually quite important for this particular
game.
Here is the situation that we have when we produce a new title and they give it the right Fauntleroy
take size.
And most importantly we give it the right title the right counter on it which is shown in here.
We have to somehow have a mechanism where we can explore this value simply because later on in the game
and I can click on tile like this one and then that one will have to be able to compare the values in
them and make sure they are of the same type or the same value is present on both of them.
Now you could simply assume that all we could actually read the value on the label.
But I want to suggest a better solution and that is why subclassing the label to store this information
summary internally.
And the reason I want to do that is simply because you may not be only dealing with things such as labels
that actually show their values.
Maybe you would be working with something like a UI image that doesn't have a value that you can't read.
So it's better if you actually have a subclass that can store this information.
Now let me show you how we are going to do that in order to do it.
I have to change some parts of my code and that's something I warned about at the beginning that one
is that by the time we will be changing the code to get to where we want to get simply because that
is how you work as a developer you don't really know everything right off the beginning as you go along.
You will find different things that you have to do.
So to do that I'm going to go in here and get myself and you file this one.
I'm going to make it a subclass of you I Lavan.
And I'm actually going to call it my label.
So it's a subclass of a label in swift language of course and it is called My label and in my labor
I'm going to go ahead and say I have a few prompters or a few attributes in here.
One of them is something I'm going to call internal numbers and that's going to be an integer and that
integer is going to be an optional explicitly wrap optional.
And then I'm going to have to a static variable one of them is a static variable let's call it question.
And that's going to be showing us a question mark.
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
show you why I'm adding these to in just a second.
So this one is going to show me an emoji of a smart and if you're wondering on a macro machine you can
press control command on the spacebar to get this emoji window.
So I'm going to get that one.
Now let's see why we have all of these.
So the internal number is stores the value of the time.
So that's quite easy to understand that we need to somehow restore the value and then later compare
them against each other compare against the other.
So that's about that.
Now I know in my iPad simulator right now we can see all the numbers but obviously that's not how the
game is going to be played.
The game will be played by all of these tiles to be flipped.
And as they are flipped I want to see a question mark on them.
So the user has to guess what's the number behind them.
So that is going to be the default presentation of all tiles.
And finally if I tapped on two similar tiles and I found them I want to be able to see this one.
So smile is the final result when we match times.
So that's about it.
Now let me take you back to the very original design of the RPG after they have actually developed before
and show you that in practice.
So when the app launches we see all the question marks.
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
me the slides Let me show you another one so the entire number is zero.
The other number is two and they all flip back to question marks.
And if I find another one of the zero or two I can actually match them against each other three and
four.
And that is three and three.
And if we find them I want to see a little smile.
Guess where I have the internal number to remember what number I need.
The question was to show by the fourth and the smile to show in case I found something.
Now we have this cause obviously we haven't used it anywhere.
So let's go ahead and use it in our actual code.
And then what of your controller.
I didn't hear.
I'm going to go ahead and see where I'm going to make the toilets instead of them making tiles of the
type I label.
I'm actually going to make them by my label type.
I'm using my leave it is going to be identical to using a label simply because my left label is a subclass
of you I label.
And because of that I can still use it in its fifth frame and I can actually use the font text and I
mean almost everything stays intact except for one thing and that is all I have to store the value that
they show on each of them inside a property called internal number.
So I'm going to go in here and say you are going to show this slide your counter on every tide and that
is the number we need to store.
So I'm going to go ahead and say Hi Dot internal number becomes counter.
So we store the value and then of course we show it there.
You could either show counter again or if you wanted to you could actually show the tiles that internal
number and since entire number is an optional value.
I have to make sure that I explicitly wrap it.
So I'll wrap it to show me the actual value and if I run the application we should be able to see the
exact same thing as if you had before but now we have a little bit of more confidence as to what's happening.
For instance this tile number five it is showing 5 and some internally it is storing the value of 5.
So that is really going to help us in the future upcoming things that we have to do.
So just keep it up to here.
In this is and we added the my label class and we use the my label class to populate our titles and
let's move on to our next lesson.