So well coming again this list is going to be one of four most important lessons in here.
We're going to deconstruct that I was and understand how the different pieces they tie together we will
not be talking specifically about the classes or object oriented programming but we have to somehow
get a sense of what they are and what they do.
So if there are parts in you that you don't fully understand don't worry about it.
There is a lesson coming up for those the part that we have to understand is the role of The View Controller
and the class part of it.
We'll get to it at some point in the future.
So this could Lexcorp India score.
I'm actually going to close this application of course I'm going to start you out and I'm going to call
this one view controller class and let's see what do we mean by that.
So essentially what you're really trying to understand is the relationship between these files.
How is the View Controller edge and The View Controller them and that view Quenta are in the main storyboard
hall or are they all connected to each other and that's essentially the goal of this lesson.
So to do that I'm going to deconstruct this this app I'm going to try to break it a few times and then
remake it.
So you get a sense of what is connected to what and how things are happening.
One concept that unfortunately I have to force on you right now is a concept of a class and that is
here at interface View Controller of a type you I view controller.
We will talk about this in for and more details in the future.
But just to understand what is happening in here I'm introducing a new object called The View Controller
and it's type or its superclass is you I view controller you would essentially write this you're sort
of you could say at interface and then the interface is going to be what they're very you know like
you can name it and it has to have a superclass the superclass.
In this case is a UI View Controller.
Maybe next time I went to Vienna's object or maybe it would be unnecessary.
That is kind of irrelevant to what we are doing right now.
But what is important for us to understand is that these names The View Controller in here and then
as well as the implementation of fit view controller and the private interface for it.
They're just names that somebody has given to an instance of a View Controller.
What is that.
That is this guy.
That's an instance of the UI View Controller.
So they have given it a name view controller and they have connected them together.
Now for us because we are trying to understand how do they work with each other.
I'm actually going to select this one I'm going to make it a green View Controller and I want to change
all of the names so that they reflect the same thing.
So I'm going to delete these comments in my that age.
I'm going to go through that and delete these comments this time I'm not going to delete my private
interface because I want to see how it works.
And like I said this lesson isn't up.
It's not something that would be challenge against play it's very important to understand the concept
of it.
So like I said if they interface view CONTOURI something that somebody has done something a change that
will mean a view controller.
So now I am saying Well I don't want it to be called just view controller.
I want it to be called Green view controller.
So whenever you have an interface that's like declaring something.
So we do have something.
So because we have the interface which is kind of our Declaration we need to also have it's definition
that definition is actually here in the implementation and it used to be called The View Controller
but now it is called the Green View Controller.
And this is like I said a private interface I'm going to change that into a green view control as well.
So now if we run this application everything works and there are no errors.
Something else will crash now.
But essentially the naming has worked.
So you might be wondering so what happens with these names.
How come these files are still called View Controller age of view control.
And that's because these names are kind of irrelevant.
You can call these files what ever you want.
These are Foy's that are on your hard disk so I can go ahead and say viewing or showing finder and it
shows you a file that says well this is the file and that's all there is to it.
So these things essentially could be called anything.
And another thing of course we name them more meaningfully.
However the moment they change this name something went wrong.
It says the file the view contorted that H is not found anymore because he was trying to import that
fine and import essentially the content of it.
Now we have named that to any teen at that age.
So apparently I have made a spelling mistake here as well.
So I have to write it and we think that age and again everything works.
Of course it doesn't really make sense that we rename our staff to sites revered names and kind of meaningless
names.
So if you want to really do this properly I would go in here and say This one is actually green view
controller that age and of course this one is the green view Quintard that.
And in my view it that and I'm going to import green view of counter-attacked h.
So by now we have managed to arrange everything.
Our interface has been called Green view controller our data and implementation has been called properly
our private interfaces called properly our importers fought real names properly and also our phones
are renamed properly.
So the next thing the most important thing in here is so how does this one know how to connect to the
green view controller.
How does this one know that it has to connect to that one.
We haven't told him that.
So here I'm going to go ahead and select my view contour or this little yellow icon on the top and I'm
going to go to one of the towns on top of here which is called the identity inspector.
And in the eye then the inspector is saying the class for this guy is a view controller but we know
we don't have that anymore.
We renamed it.
So I'm going to say no it's actually green a view control.
So with that now everything is connected to each other and everything is now working based on our new
names.
So you might be wondering.
So what was the purpose of this entire practice.
How is that going to help us with any real application the way it is going to help us.
Is this fun little going here an odd a new view controller and that new View Controller is going to
be a pink background.
Or it could be your contact information I could be the stories of your application it could be the share
of the media off your chat application whatever it is.
So this is my pincher view controller and I have to connect it to someone in here.
Code Pink.
You can tell but I don't have that.
So I have to actually add the doors as a file.
So let's see how we're going to do that.
And when I go to file new file and file new file I'm going to say I had a Cocco touch class from the
U.S. and the cocoa touch class.
I'm going to say the language is Objective-C and the subclass is you.
I view controller and the name is pinch view controller.
So once again just copy all of these so I don't have to retype them.
I'm going to have the command on an all go to file new new file.
And then you find I'm going to say I want to talk Cocco to each class and I want to be called pinchy
view controller because this view contour is pink.
It has to be a subclass of you are View Controller.
The say next and fill out two files to my project.
These two files are these two pins you control at that age and you control that.
And these are the View Controller class files of my upcoming Pinku View Controller.
So let's go to my main a storyboard and in here I'm going to say this guy is actually in the identity
inspector is connected to pinch view controller.
So now the Pincio controller here the pinkish color one is connected to some one called Pincio control
then the green one is connected to some one called Green view controller.
And everyone can work on their own independently.
Essentially I know I'm stretching this a little bit or maybe it seems you know out of place but they
want to explain this really quickly as well that you don't necessarily need to make extra finds using
the r command and cocotte touch class.
These are just text files that text files that they have some values written in them and that's all
there is there is to it.
So for instance I could do this I could say I have another one another view controller view controller
is actually going to be my.
What other callers do I have in here.
My blue view controller in here I'm going to go ahead and say Give me a new empty file that you find
one that's the empty file.
I'm going to call it blue the view controller dot H.
I'm going to add it in there.
I'm going to add another one.
And again an empty file that doesn't have any relations with anyone.
I'm going to call it blue view controller dot.
So just like that default one that the machine made for me are making my own version.
And inside these two here's what I'm going to do in the dark h of the blue of your control.
I'm going to say that interface and that is called the new View Controller superclass.
Easy you I view controller.
Now what I try to type in you I view CONTOURI it doesn't autocomplete for me and soon it's going to
give me an error because it says I don't know which library you're trying to import from if you go to
the other that etches you will see that the library you Kit is imported by the font.
So when you go in here and say well you know what you actually have to import you I.
And for some reason it doesn't autocomplete for me.
So I'm going to have to try it.
Do I get you I get that age and then I'm going to go to Blue view contorted them them I'm going to say
import what do I want to import.
I want to import blue of your cuenta are at that age when I want to write the implementation.
What do I want to write the implementation for you control.
What are the metals that I need.
There's only one method that they actually need.
Even that we don't really need it.
That is called view of the Lord and the only thing we want to do from it is super view that look.
So this now becomes quite identical to what we have in the green view controller.
And what we have in the pink one.
So I was kind of a deconstruction of all of these.
And of course now I can go in yet and say this guy who is bluish in that identity is actually connected
to The View Controller.
So now if we go in here and we say if you run this application now obviously the green one is going
to run.
So now the green light is being shown.
If I move the initial view control over this little thing and you initial view onto it the pink one
you fear on it the pink one is going to run
all right.
And here's what I'm going to do.
I'm going to go in here and I'm going to add some labels.
I'm going to say I have a label here that is like this right.
And this label has much larger text on the background of it is actually white.
All right.
I'm going to copy that here in my blue one as well.
And I'm going to copy it here in the green one as well.
All right.
And then I'm going to load up my assistant editor in here and I'm going to say for the green one for
they want to see is green view controller that H and I want to add this label it's my label.
All right.
And then I want to go to the pinch one for the pink one.
I want to load pinch view controller that H I want to get rid of everything that I know I don't need
to I don't need dollars and they don't need this here.
I want to drive this guy again.
Uncoiling gets my label because this is my label for the pinch.
That was my label for the green and now I'm going to go see a blue one.
And for the blue one and learn a lot the viewpoints are at that age.
The one that I have written myself and when I write the label and that's one again I'm going to call
it my label.
So they're all record my label.
But when I go to my editor and I go to View QUANTRILL the green one in the view of the.
I'm going to save my labor.
That text is going to say this is Urim If we load the blue one he's gonna say my label.
That text is this is blue.
And of course if I do this in the pink Tron we expect him to say this is.
Now the pink one.
Because the machine generated for us it has some extra stuff in it.
You don't need any of them so you can just delete everything just like what you have been doing so far.
So we keep viewed that lot.
We get rid of all the comments on every other method.
And now my initial view contour is the paint one.
So if we run it it should say this is paying hopefully if it all works and if I set my initial on to
be the blue one I run it is going to say this is blue and that's what we need to see.
We get to see how these de-friend view controllers are connected to different view Quintard classes
and how they are independent from each other how each of them have their own age and and how each of
them is properly connected to a certain class hearing the identity inspector.
So the blue event is connected to the blue one the pink phantom the pink one the green once again one
so on and so forth and how each of them have their own properties and functions and methods and they
were completely independent from each other.
So with that in mind we're going to move on to our next lesson.
Where are we going to make connections between these unbe going to know where we are going because in
the previous lesson when we made segues we only knew that from going one going to the pink one.
But we didn't know there an actual Pinchem view controller class this time we're going to know that
I'm going to use that to our advantage so that our segues they know exactly where they are going.
And as a result we can actually go back.
So let's keep it up to here in the next lesson.
I'm going to make another two controllers and do navigation between them.