1 00:00:00,420 --> 00:00:09,030 Bryant, it is time to start sending data to Firebase, so what we're going to do here is start to listen 2 00:00:09,030 --> 00:00:10,350 to this text field. 3 00:00:10,350 --> 00:00:18,560 When the user enters a message, we're going to do this by having a UI text field delegate. 4 00:00:19,020 --> 00:00:22,230 So this is going to listen to changes in the text field. 5 00:00:25,970 --> 00:00:33,530 To set this up, we're going to have the reference to the message TextField going to set the delegate 6 00:00:35,000 --> 00:00:35,600 to self. 7 00:00:38,470 --> 00:00:40,270 So that should take care of that. 8 00:00:40,900 --> 00:00:45,520 Now, this delegate, we're going to have to obviously do something, aren't we? 9 00:00:46,090 --> 00:00:47,810 So this is my finished code here. 10 00:00:49,330 --> 00:00:54,280 Let's check out our TextField should return. 11 00:00:57,160 --> 00:00:59,500 So let's put it perhaps under fire based. 12 00:01:03,590 --> 00:01:10,220 Now, what we're doing in the TextField should return is this is part of the delegates, so when something 13 00:01:10,220 --> 00:01:17,330 changes in the TextField, i.e. you type something and then you press enter, what happens is this gets 14 00:01:17,330 --> 00:01:17,940 fired. 15 00:01:18,350 --> 00:01:24,800 What we're going to do is check the count of this particular textfield, as in are there enough characters? 16 00:01:24,920 --> 00:01:29,030 If it's less than one, which means there's nothing, then we're going to say, hey, you can't send 17 00:01:29,030 --> 00:01:32,510 that the thing over that, then you are fine. 18 00:01:33,350 --> 00:01:37,430 We are going to create a data object. 19 00:01:37,850 --> 00:01:43,940 This data object is what's going to fit into our FIREBASE database. 20 00:01:44,330 --> 00:01:50,620 So it has a text field which contains the text from the text field. 21 00:01:50,900 --> 00:01:57,230 OK, so we're just using these constants to name things so we don't get a a copying error somewhere 22 00:01:57,230 --> 00:01:58,100 in our own code. 23 00:01:58,970 --> 00:02:02,280 Then we're going to send the message which we haven't explicitly set up yet. 24 00:02:02,280 --> 00:02:04,130 So I'm just going to comment that out. 25 00:02:05,600 --> 00:02:10,190 We're going to print something to ourselves so we can tell ourselves with doing something as a developer. 26 00:02:11,240 --> 00:02:14,810 And then finally, if we so wish, we can clear the text field. 27 00:02:15,080 --> 00:02:18,020 Let's go ahead and drop that into utilities. 28 00:02:18,980 --> 00:02:19,580 So. 29 00:02:21,340 --> 00:02:28,610 There's our clear textfield now, the reason I put this into utilities is because we might have to do 30 00:02:28,610 --> 00:02:31,330 it in other places with a messaging app. 31 00:02:31,600 --> 00:02:34,660 You could imagine you're putting your name in, you're putting the time in. 32 00:02:34,660 --> 00:02:36,070 You're doing a whole bunch of things. 33 00:02:36,340 --> 00:02:38,980 You might want to clear the text field quite often. 34 00:02:39,580 --> 00:02:45,010 So I'm just going to pass it, the reference to the text field and that is going to clear it so that 35 00:02:45,220 --> 00:02:46,480 I should now go away. 36 00:02:46,870 --> 00:02:47,580 Going out. 37 00:02:47,890 --> 00:02:48,840 Shoo, shoo. 38 00:02:50,650 --> 00:02:52,630 Well, it'll get rid of itself eventually. 39 00:02:53,650 --> 00:03:00,550 OK, so this is hooking up to the text field so we can tap in to what's going on with the text. 40 00:03:01,000 --> 00:03:05,830 And then in the next section we're actually going to send that firebase message.