Now, what I like to do whenever I'm creating an app with something like a table view is I like to populate
it with some dummy data.
So I know that all my functions are working right.
The danger of using Firebase for this whilst Firebase is fantastic, we don't know if we actually have
the data streaming through.
So if it doesn't show in the table view, you now have to go down this long rabbit hole of discovering
what happened to the data and why the table view isn't doing what you need it to do.
And as a developer, you go through that all the time.
So what I like to do is take these very slow in small stages, which ironically is actually faster than
just jumping on and doing everything at once.
So what we're going to do here is get the cell for row at.
So we are going to specify how what we're going to put in the cells and we're going to have the number
of rows in section.
And all we're going to do for that is going to return, let's say one hundred.
We're just going to populate this with 100 rows.
Then we're going to populate those hundred rows with some code.
So I've got some code here that I'm just going to paste in.
Feel free to pause and copy this if you need to.
We're going to define our cell, which is a UI table view cell, by going to the table view and decoding
a reusable cell with an identifier called Message Table View Cell.
So I'm going to copy that identifier can go to the main storyboard and I'm going to tap this cell.
Now, when you tap it, ensure that over here on the left, see what I'm tapping, it hasn't selected
the content view you need to select the cell.
OK, so storyboards in Xcode are notorious for doing this.
As far as I'm concerned, you usually select the wrong thing over here on the right side in the reuse
identifier.
Just drop a paste into there and hit enter.
And now we have the cell defined.
So if I hit play on this, while it's not going to work because we haven't yet returned that cell,
but now if I hit play on the iPod Touch, it's not going to populate the cell.
It's not going to do anything particular with it.
It's just we're just making sure that this cell can be grabbed.
OK.
And there we have it, so we have 100 cells, and if I just scroll, we're left with the bog standard
text title and subtitle until we get all the way to the bottom.
And, of course, all the way to the top.
OK, so we know that all works now stop that running so it doesn't mess up my Mac, what are we going
to do now?
Well, let's see what the other code is here while I've got this message which will get on to you when
we get to the firebase part.
Got a message content.
And we have some other items here, so I think what we're going to do for these particular items is
leave that until we get to the firebase part of this, because this is all firebase related.
If we weren't using Firebase, the relevant lines, for your information would be this one and this
one.
OK, and if you had a custom cell, then you wouldn't have detailed or text.
You'd have the particular things that you'd created in the cell.
OK, now we do need to copy this.
Did select row at.
OK, so instead of copying it, what I'm going to do is just type did select row at because that old
code is fairly old and something might have changed.
And what we're going to do here is get our table view.
You see now it's bringing up the table view in this method or the table view in the class.
And it's really difficult to tell which is which.
I believe it's this top one.
We'll see, though, although in theory it doesn't matter because they are the same thing.
So we want the deselect row at the index path that we've passed in and animated, let's have true because
as things stand, if I tap the row that gray bastard's stuck on.
But as long as we have this deselect row, the gray bar will go away.
So whilst that's loading, let's see what else we've got to do here.
We can specify the number of sections which we don't have to do.
There's our deselect working, but I find it helps.
What does it help with?
It helps to have a full set of the table view functions I use most often and then I just copy that over
between applications.
So I know that I'm tackling all the things that I need to tackle.
So if we get a number of sections in the table view, we can just return one.
Now, clearly we don't need this right now because it by default it goes to one.
But later on in your app, you might actually want to separate your table, your rows out into sections,
in which case you would have to update that.
OK, so that's our table view working.
That's how we set the delegates and that's how we implement all the table view functions.