Bryant, it is time to start sending data to Firebase, so what we're going to do here is start to listen
to this text field.
When the user enters a message, we're going to do this by having a UI text field delegate.
So this is going to listen to changes in the text field.
To set this up, we're going to have the reference to the message TextField going to set the delegate
to self.
So that should take care of that.
Now, this delegate, we're going to have to obviously do something, aren't we?
So this is my finished code here.
Let's check out our TextField should return.
So let's put it perhaps under fire based.
Now, what we're doing in the TextField should return is this is part of the delegates, so when something
changes in the TextField, i.e. you type something and then you press enter, what happens is this gets
fired.
What we're going to do is check the count of this particular textfield, as in are there enough characters?
If it's less than one, which means there's nothing, then we're going to say, hey, you can't send
that the thing over that, then you are fine.
We are going to create a data object.
This data object is what's going to fit into our FIREBASE database.
So it has a text field which contains the text from the text field.
OK, so we're just using these constants to name things so we don't get a a copying error somewhere
in our own code.
Then we're going to send the message which we haven't explicitly set up yet.
So I'm just going to comment that out.
We're going to print something to ourselves so we can tell ourselves with doing something as a developer.
And then finally, if we so wish, we can clear the text field.
Let's go ahead and drop that into utilities.
So.
There's our clear textfield now, the reason I put this into utilities is because we might have to do
it in other places with a messaging app.
You could imagine you're putting your name in, you're putting the time in.
You're doing a whole bunch of things.
You might want to clear the text field quite often.
So I'm just going to pass it, the reference to the text field and that is going to clear it so that
I should now go away.
Going out.
Shoo, shoo.
Well, it'll get rid of itself eventually.
OK, so this is hooking up to the text field so we can tap in to what's going on with the text.
And then in the next section we're actually going to send that firebase message.