-
Okay.
Now, we want to connect up our
-
button the way we did for the label.
-
First, let's make a little room for the
button by moving this label up a bit.
-
And, we'll need to open up our utilities
pane, so we can drag in the button.
-
There we go.
-
While we have this utilities pane on
the right open, let's go ahead and
-
set the titles on this button and label.
-
To do that, you're going to want to
go to the attributes inspector, and
-
then you can see,
here's where our title gets set.
-
We'll just say Click.
-
And then, for the label, let's just
set it's original text to zero.
-
Let's close our utilities pane for
now and move this back to the center.
-
And next up, we're going to set
target action on this button.
-
First up, let's open up our
view controller file for
-
a little review on target action.
-
Recall that the target action
that we added programatically
-
had three key components.
-
Its target, which was self, the action,
which was the method increment count,
-
and the event that would trigger
that action, touch up inside.
-
So, now, we're going to use
storyboard to tie together these
-
same three pieces of information.
-
But first, we need to mark
this method as an IB action
-
to that it actually
shows up in story board.
-
Similar to how we did
with the label property.
-
And, we can close our
assistant editor for now and
-
focus on story board, and
then move this over a bit.
-
And, to set our target action,
first we bring up the button's
-
pop up connections menu,
go down to touch up inside,
-
drag to our view controller, and choose
the method we want our to be our action.
-
I'm just going to remove that
target action really quick, so
-
I can show you how to
make it one other way.
-
Using the canvas view,
you can still get to this menu.
-
Go from touch up inside to
the view controller, and
-
then the method increment count.
-
And, you can see the three key
components of the target action.
-
Let's go ahead and run it so
we can see it in action.
-
And if we click on the button,
we can see our count incrementing.
-
So, that ought to take
care of click counter.
-
Remember how our label
had an optional type?
-
Next up,
-
Jason's going to tell you all about
optionals in the first Swift session