So will come back again in this list and we're going to talk about Bartons views pardons for a variety
of things for calling functions for revealing values for submitting forms for logging in a user.
So Boland's all of those are fundamental pieces of any Iowas application.
So let's go ahead and get started making some burns.
Of those books Lexcorp I'm going to start a new project.
This is going to be an Iowa single new application and I'm going to call it Baden's.
And then my Baden's up once it loads up when I go to my main storyboard I'm going to show you several
different ways of making by then obviously if you start from the simplest one.
So in the simplest one I'm going to go to a library and here I'm going to search for buttons.
I'm going to add a button.
So this is a button that I have and I'm going to place it in here.
Let's go to the attributes.
Let me bring that up.
Call it our top on this and I'm going to go with a different background.
So it is more clearly visible.
Maybe not that one.
Maybe that was a porcelain actually.
So dark was good.
And then when I'm going to do is I'm going to add a label in here.
So here is that label I'm going to label that as above.
Perfect my label is aligned to the sun a little bit larger and it has a background of pink.
That's all I'm doing here.
So the next thing I'm going to do is I'm going to actually go ahead and connect these outlets to my
programming interface so to do that I'm going to go to the assistant editor and the assistant and I'm
going to make sure that I have my user interface loader in one side and my daughter age on the other
side.
At that age I'm going to go ahead hold control and drag my label and hitting the out that I'm going
to say.
It's called resort labor.
And now the connection type is an outlet to remember that connect.
But when I'm driving my car then I'm driving this over here and the connection type I'm going to change
it from outlet to be an action.
So this time when this thing gets stopped on I want something to happen to change a connection to an
action.
I don't want to call it our top action.
So let's see what we get.
So fine go back to the other two I'm not.
I go to my dad page in here.
I have one property that is declaring declaring the outlets right.
Take Larry out with or without declaring the outlet and then I have an action an action which is to
be triggered every time we stop on that button and I have the same action in my dad am and he's asking
me to fill the body of my function.
Actions and functions can be used interchangeably in innocuous I mean in terms of terminology.
So this is again a function so I can call the function and I have to not do something in the body of
the function.
Now let's go ahead and do that before I do anything.
I want to clean my cord so it's not very overwhelming so I'm going to go to that age and want to get
rid of everything that is up there.
That's my interface.
That's the outlet that made this is the action.
So we know there's only these two lines and they're both made automatically using the assistant editor.
And I can go to my daughter then I can remove everything up there I can at it's my view to a lot.
You could actually delete the entire interface as well.
This is a private interface for that.
And we'll talk about that in the future.
But you don't really need it for now so you can read that and just keep the implementation here.
So what do we want to happen when we stop on that button.
I want the label in here.
This one is called the resort label.
I want to show my name.
So when I go in here and say well read the label dot text and now that we have a bit of a better understanding
about programming we can see that text is expecting and this is Thring.
So text becomes my name and what I mean.
So that's about that.
So we have that is off label and the text becomes a mirror every time we stop and let's try this socage
once it launches on the simulator.
However if it does show up sometime today.
OK.
So when I tap this label it becomes I mean perfect.
So we might manage to make a a button that triggers something.
And this is the very first time we are doing something interactive.
Now let's quickly have a look at what we have done.
So in our age we have a property that is connected to our label and we have an action that is connected
to a button.
What if I had another action let's write the shown on our on and try to connect that to our product.
We want to go in here and say it's an IB action and it's going to be called my sac in action and that's
about that.
So I have another action very similar to this format up there.
There was the return of an IB action interface based auction and they both receive any kind of send.
So essentially what it is a body in order a segment the sequence or anyone can essentially trigger them.
Now this little icon on the side it shows us that these two are connected to some one but this one the
new one is not connected to anyone.
So let's see how we could actually connect them.
I'm going to go to my main storyboard and my main storyboard.
I'm going to select the view controller on top of my view controllers interface when I select that and
I'm going to go up here into the connections inspector.
So up here in the connection the inspector tells me Reza label is connected to there.
It also tells me that the action on touch up inside is connected to that.
Pardon me.
Zoom out a little bit.
That one.
So here's what I'm going to do.
I'm going to say let's remove that connection and we'll press the red cross on the side.
And I'm going to connect my second action right.
One in here.
I'm going let's go.
A little window pops and says in what situation would you like to run this action.
And I'm going to say I want to run it when I touch up inside the button.
That means I let go of that touch inside the body of that button which is the default behavior.
Now you might be wondering so where were these things when we were doing them using the assistant editor.
So let's show it one more time.
And yet I'm going to go to the assistant director again.
Yes it's not on the right.
I have the H on the left they have my storyboard.
I'm going to drive more one anywhere here and here I'm going to say in a sort of an outlet make an action.
And in here it says in what events do you want to call.
That's what I say in touch up inside and that's the default behavior.
That's how it got called the first time we made the action.
So if you do it by dragging over that's how you do it.
If you want to do it manually you can just write your own method or function in here and then go back
to your restorable storyboards select your files on enter and then go to the connections later and connect
the one that you want.
So I'm going to connect my second action and say touch up inside.
So now whenever this button is tapped on this function will it be caught my second action.
But my second action doesn't have any body on the body of the that should be written in that thought
Am.
So just like the last time I'm going to have to bring this function once again in here and write the
body off it may be in the body of it.
I want the same thing happen I want it to say hello world.
So let's run this now.
And then we stop this one says hello world.
Another thing that you want to keep in mind is everything here is essentially in the same format.
So the property is this one is Can they connect that it's called the record label.
If you want to connect it to a different property you just changed that name.
Let's call this on my label.
And now if I go to my storyboard I can go up here and it says the outlets that I have is there is a
label on my label I'm going to disconnected from resurvey but I'm actually connected to the my label
and that's about that.
So now we made that connection between my label and this guy and that one didn't disappear for some
reason.
That made me select everything OK.
So it's now updated and refreshed properly.
So now obviously whatever we want to do we have to do it on an outlet called my label because red label
doesn't exist in our interface anymore.
So that's about that.
Another thing that you might be wondering is why didn't think it would use an outlet for our label.
But we didn't want to use one for our.
But then how come our body doesn't need an outlet.
The reason is our button itself.
You're not really doing anything right if you're just calling an action on it.
If you wanted to make your actions programmatically then we needed to introduce our buttons as well.
Let's see how that works.
So here's what I'm going to do.
I'm well remove my labor.
I'm going to say only better is labor.
I'm working with most of my action or both of my functions so I only have one label in here.
Let's go to the storyboard and the centrist thing thing because if you run the application if I run
the application it would actually crash.
And the reason for it is it's saying I'm looking for someone called my label but that doesn't exist
anymore.
Somehow you have deleted that.
So I'm going to get rid of it.
So no that's not there anymore.
I'm also going to say there is no function here because we have actually deleted that function as well.
And now here's what we're going to be doing.
I'm going to say this goes to the assistant editor.
And here there I might buy them in here and call it my button.
Now remember this time I'm not making an action or making an outlet.
So now I have my pardon and we have the arrest label which is not connected.
So let's go ahead and connect that in here.
I'm going to say it the label is disgusting.
So they're both now properly connected.
Now let's jump back into that again and I'm going to quickly refresh your memory that if we don't meet
these guys we might buy them that thing exists and we do have read the label also.
That thing is there.
So this time around we have the pardon but it's not calling a function hobbit's outlet.
So how could we call a function here and we're going here and this is how we do it programmatically.
I'm going to say might buy them at the target.
And now let's see what is this odd target which is a bit of a mouthful.
You know function has got several different parameters in it.
I a all of them so it's a little bit easier.
Bill makes sense in end just as I can to you.
So the first thing is Vin where are you are the target from.
I'm going to say set.
We will talk more about self with as you can see silf is the view controller self refers to the class
that you are programming on and most often when you yourself you mean the view controller.
Not always but most often.
You mean the view controller.
So I'm saying there is a target in here in this implementation to end in this far part.
There is a function I want you to call this thing so what's the name of that action.
So let me make that action.
That action is where it change the label.
Right.
So I'm say I selector change laborer's again.
What is a selector.
We'll come back with in in a few lessons from now.
But for now you need to learn that whenever you want to call an action you need to get a selector to
that action.
So I'm going to say Action selector change label get this label this change labor function and then
saying what type of events the event I want to use is UI control events tuckshop inside just events
touch up inside.
Exactly the that you then we're using the interface builder.
So to recap if you have the outgrowth of our bar then we say that but then our target team here look
for a function through a selector called whatever you call that.
In this case change label on the trigger it depending on a certain situation which is in your ears touch
up inside.
And what do we want to happen.
We want to say label the hard text.
This was for romantic that's about that.
So I don't get those two.
Let's move on thought
on here.
It shows up top on something.
This was programmatic.
So we saw essentially three different ways of connecting buttons and running you know functions with
buttons one of them was a Baden's of what is true a c stands at itself.
Another one was but or action is called from Interface Builder.
And finally it was actions caused by that target.
So three different ways of calling buttons and calling functions through buttons and this one add a
lot of interactivity to everything that you are doing.
So with that in mind let's move on to access.