It's time to start hooking up this table view.
Now, I have done this with you before, if you've seen tutorials on the table view controller, but
that kind of implements everything for us.
So we're going to have to do this manually because we want to items on the screen, both the table view
and this textfield down at the bottom here.
OK, so let's see how we go about doing that.
First of all, let's hit this icon at the top right here.
And let's open up our view controller and let's start implementing or rather let's first connect the
table view to the view controller.
So Control click and drag it up here and let's just call this table view.
We don't need to give it a special name because there is only one table view in each view.
And if you are a good developer, that's the way it should always be.
One table view in each view.
Let's get this leg up over here.
Come on, you can do it.
There we go.
And this is going to be the message, TextField.
OK, so we'll use the message TextField later on.
We're not interested in that right now.
First of all, we have to set up this table view.
So I'm going to switch to my finished app and I'm just going to copy over these three items and then
explain what they are once they're in.
But let's get rid of this section so you can see everything that's going on here.
So, first of all, our table view needs a data source.
That's what we're implying here.
It needs a table view delegate, i.e., what do I do when things are happening and the UI TextField
delegate?
Well, that isn't actually part of this, so I'm just going to remove that for now at least.
I don't think it was part of it.
It's probably related to the UI text field.
OK, so forgetting the text field stuff, let's look at the table view.
So these two items I've added, it tells us that you don't have the protocols from data source and if
you tap fix, it's going to throw in a couple code stubs for us.
That is the number of rows and section and the sell for Roett.
So this just returns how many rows there are in our table for each particular section.
We only have one section because we're not dealing with that right now.
And the cell phone that allows us to populate that particular cell, as in the what is it, the subtitle
cell that we created.
So if I make this bit clearer for you, that cell there, which is of type subtitle.
OK, so that's what that's doing now.
This still isn't going to work.
And why is that?
Well, we actually have to tell our application that it needs to assign these things to this table view.
But before we do that, I'm just going to cut this command X and I'm just going to paste it below.
You did load.
And if you want, you can do things like this mock stock table view.
And then end table the.
OK, got a code there, just double click, it goes away.
Now, what do we have to do?
Well, this needs return functions.
We're not going to bother with that right now.
But in our view, did load.
We are going to have our table view.
Dot delegate is equal to self.
So what we're doing there is saying anything the table view does.
I want you to look for those particular methods in this particular class.
That's basically what that means.
The UI table, you delegate so the system knows.
If I tap something, if I do something, if I scroll, just go ahead and look in this view controller
and you'll find all the methods that you need to make things happen, including some functions we can
actually see here and we don't need to see or even know about ever in our development career.
So that's less to learn.
Now, there are some other things that we need to set here.
So table view, dot data source, I think that's going to be self as well.
But I'm just going to check my code over here.
Yes.
So we have a delegate, we have a data source and there's the stuff for the text field, but we're not
going to do that just yet.
So basically these two lines of code set up our table view and link it to this view controller so that
we can start doing these bits and pieces with that particular table view, which will do in the next
section.