1 00:00:00,420 --> 00:00:04,180 It's time to start hooking up this table view. 2 00:00:04,650 --> 00:00:09,240 Now, I have done this with you before, if you've seen tutorials on the table view controller, but 3 00:00:09,240 --> 00:00:11,960 that kind of implements everything for us. 4 00:00:11,970 --> 00:00:17,010 So we're going to have to do this manually because we want to items on the screen, both the table view 5 00:00:17,340 --> 00:00:19,920 and this textfield down at the bottom here. 6 00:00:20,870 --> 00:00:23,070 OK, so let's see how we go about doing that. 7 00:00:23,100 --> 00:00:25,620 First of all, let's hit this icon at the top right here. 8 00:00:27,360 --> 00:00:33,150 And let's open up our view controller and let's start implementing or rather let's first connect the 9 00:00:33,150 --> 00:00:34,620 table view to the view controller. 10 00:00:34,640 --> 00:00:40,050 So Control click and drag it up here and let's just call this table view. 11 00:00:40,060 --> 00:00:45,690 We don't need to give it a special name because there is only one table view in each view. 12 00:00:45,900 --> 00:00:49,230 And if you are a good developer, that's the way it should always be. 13 00:00:49,230 --> 00:00:51,810 One table view in each view. 14 00:00:53,860 --> 00:00:55,790 Let's get this leg up over here. 15 00:00:56,650 --> 00:00:57,760 Come on, you can do it. 16 00:00:58,420 --> 00:00:58,920 There we go. 17 00:00:59,950 --> 00:01:04,600 And this is going to be the message, TextField. 18 00:01:06,830 --> 00:01:09,600 OK, so we'll use the message TextField later on. 19 00:01:09,620 --> 00:01:11,050 We're not interested in that right now. 20 00:01:11,480 --> 00:01:13,820 First of all, we have to set up this table view. 21 00:01:14,360 --> 00:01:20,810 So I'm going to switch to my finished app and I'm just going to copy over these three items and then 22 00:01:20,810 --> 00:01:23,270 explain what they are once they're in. 23 00:01:23,990 --> 00:01:28,310 But let's get rid of this section so you can see everything that's going on here. 24 00:01:29,360 --> 00:01:32,110 So, first of all, our table view needs a data source. 25 00:01:32,600 --> 00:01:34,820 That's what we're implying here. 26 00:01:35,360 --> 00:01:42,770 It needs a table view delegate, i.e., what do I do when things are happening and the UI TextField 27 00:01:42,770 --> 00:01:43,260 delegate? 28 00:01:43,280 --> 00:01:48,160 Well, that isn't actually part of this, so I'm just going to remove that for now at least. 29 00:01:48,170 --> 00:01:49,450 I don't think it was part of it. 30 00:01:49,730 --> 00:01:52,730 It's probably related to the UI text field. 31 00:01:53,360 --> 00:01:56,620 OK, so forgetting the text field stuff, let's look at the table view. 32 00:01:57,290 --> 00:02:04,970 So these two items I've added, it tells us that you don't have the protocols from data source and if 33 00:02:04,970 --> 00:02:09,050 you tap fix, it's going to throw in a couple code stubs for us. 34 00:02:09,860 --> 00:02:13,780 That is the number of rows and section and the sell for Roett. 35 00:02:14,060 --> 00:02:19,660 So this just returns how many rows there are in our table for each particular section. 36 00:02:19,880 --> 00:02:22,810 We only have one section because we're not dealing with that right now. 37 00:02:23,630 --> 00:02:32,870 And the cell phone that allows us to populate that particular cell, as in the what is it, the subtitle 38 00:02:32,870 --> 00:02:34,340 cell that we created. 39 00:02:34,790 --> 00:02:42,570 So if I make this bit clearer for you, that cell there, which is of type subtitle. 40 00:02:43,700 --> 00:02:47,330 OK, so that's what that's doing now. 41 00:02:47,330 --> 00:02:49,240 This still isn't going to work. 42 00:02:49,250 --> 00:02:50,180 And why is that? 43 00:02:50,450 --> 00:02:57,320 Well, we actually have to tell our application that it needs to assign these things to this table view. 44 00:02:57,680 --> 00:03:04,440 But before we do that, I'm just going to cut this command X and I'm just going to paste it below. 45 00:03:04,460 --> 00:03:05,120 You did load. 46 00:03:06,260 --> 00:03:10,610 And if you want, you can do things like this mock stock table view. 47 00:03:13,090 --> 00:03:14,680 And then end table the. 48 00:03:17,060 --> 00:03:20,520 OK, got a code there, just double click, it goes away. 49 00:03:21,530 --> 00:03:23,030 Now, what do we have to do? 50 00:03:23,810 --> 00:03:25,850 Well, this needs return functions. 51 00:03:25,850 --> 00:03:27,890 We're not going to bother with that right now. 52 00:03:28,520 --> 00:03:30,170 But in our view, did load. 53 00:03:30,410 --> 00:03:32,480 We are going to have our table view. 54 00:03:32,960 --> 00:03:37,370 Dot delegate is equal to self. 55 00:03:38,090 --> 00:03:41,450 So what we're doing there is saying anything the table view does. 56 00:03:41,600 --> 00:03:46,640 I want you to look for those particular methods in this particular class. 57 00:03:47,270 --> 00:03:49,460 That's basically what that means. 58 00:03:49,460 --> 00:03:52,130 The UI table, you delegate so the system knows. 59 00:03:52,130 --> 00:03:56,960 If I tap something, if I do something, if I scroll, just go ahead and look in this view controller 60 00:03:56,960 --> 00:04:03,170 and you'll find all the methods that you need to make things happen, including some functions we can 61 00:04:03,170 --> 00:04:08,570 actually see here and we don't need to see or even know about ever in our development career. 62 00:04:08,990 --> 00:04:10,040 So that's less to learn. 63 00:04:10,460 --> 00:04:13,850 Now, there are some other things that we need to set here. 64 00:04:14,150 --> 00:04:20,870 So table view, dot data source, I think that's going to be self as well. 65 00:04:21,080 --> 00:04:22,960 But I'm just going to check my code over here. 66 00:04:23,660 --> 00:04:23,990 Yes. 67 00:04:23,990 --> 00:04:29,510 So we have a delegate, we have a data source and there's the stuff for the text field, but we're not 68 00:04:29,510 --> 00:04:30,450 going to do that just yet. 69 00:04:30,890 --> 00:04:39,770 So basically these two lines of code set up our table view and link it to this view controller so that 70 00:04:39,950 --> 00:04:45,530 we can start doing these bits and pieces with that particular table view, which will do in the next 71 00:04:45,530 --> 00:04:45,950 section.