1
00:00:04,900 --> 00:00:10,060
Welcome back to class everyone Johnny B here with slopes dot com and in this lesson we are continuing

2
00:00:10,060 --> 00:00:11,900
working on our comments.

3
00:00:11,920 --> 00:00:19,860
VC we are just kind of laying the groundwork so that we can pull in common data once we get that added.

4
00:00:19,900 --> 00:00:29,230
So in that last lesson we have created are you I in the main story board we got our table view and actually

5
00:00:29,230 --> 00:00:37,160
I need to add some constraints on this table you need to go 0 0 0 and 0 had those four constraints.

6
00:00:37,360 --> 00:00:37,770
There we go.

7
00:00:37,810 --> 00:00:38,870
That looks better.

8
00:00:39,160 --> 00:00:48,500
And then in our comments we see we have the beginnings of what we need to add for our table to work.

9
00:00:48,640 --> 00:00:53,400
So when you were working with table use obviously we need our table view delegate and datasource let's

10
00:00:53,410 --> 00:01:02,460
add those say Table View delegate and you table view data source.

11
00:01:02,460 --> 00:01:03,410
There you go.

12
00:01:03,910 --> 00:01:06,700
And then let's go ahead and set those and viewed it.

13
00:01:06,720 --> 00:01:10,800
So to get to see Table View dot delegate is equal to self.

14
00:01:10,990 --> 00:01:18,510
No not that self table view that data source is equal to self.

15
00:01:18,980 --> 00:01:19,400
Okay.

16
00:01:19,420 --> 00:01:25,040
And then we need to add a couple of methods that are required for these protocols.

17
00:01:25,170 --> 00:01:32,830
Case So those are going to give a little bit space here to get this up to the middle and those are number

18
00:01:32,830 --> 00:01:39,370
of rows in section now just return 0 and then

19
00:01:42,440 --> 00:01:44,960
sell for row index path.

20
00:01:45,270 --> 00:01:51,290
And here I'll just return you my table a view so generic for now.

21
00:01:51,680 --> 00:01:52,460
Okay.

22
00:01:52,480 --> 00:02:01,440
So jump into our main VC does Swift just kind of refresh how the how this works what we need is a an

23
00:02:01,470 --> 00:02:07,260
array of items that we can add to our table view.

24
00:02:07,470 --> 00:02:10,620
In the case of the main DC it was an array of thoughts.

25
00:02:10,680 --> 00:02:10,950
Okay.

26
00:02:10,950 --> 00:02:16,970
And so because of that we created a thought model and it had all of this stuff.

27
00:02:17,250 --> 00:02:23,840
And then our main VC we were able to go through and look through those and dequeue sales based on that.

28
00:02:24,100 --> 00:02:24,530
Okay.

29
00:02:24,660 --> 00:02:27,900
So in our comments AVC we're going to be doing the same thing.

30
00:02:27,970 --> 00:02:33,330
So we're going to need a new class but instead of us thought this is going to be a comment but it's

31
00:02:33,330 --> 00:02:34,540
going to be very similar.

32
00:02:34,860 --> 00:02:40,630
In fact it's going to be so similar that I'm actually going to copy and paste most of it just to say

33
00:02:40,680 --> 00:02:44,130
some time when I say new file I say next.

34
00:02:44,130 --> 00:02:47,590
And actually we can go back.

35
00:02:47,760 --> 00:02:50,930
This can just be a swift file actually as a swift file.

36
00:02:51,080 --> 00:02:55,190
Let's say next and we're going to call this comment.

37
00:02:55,620 --> 00:02:58,650
So this is a model file for our comment.

38
00:02:58,700 --> 00:03:01,520
All right then I'm going to open our hearts with the file.

39
00:03:01,830 --> 00:03:04,110
And like I said this is going to be very similar.

40
00:03:04,120 --> 00:03:08,460
So I'm actually just going to copy this whole thing here.

41
00:03:08,720 --> 00:03:09,740
OK.

42
00:03:10,050 --> 00:03:12,900
I'm going to copy it and paste it here.

43
00:03:14,750 --> 00:03:20,810
After I do find the class a say class comment.

44
00:03:21,780 --> 00:03:22,370
There you go.

45
00:03:22,610 --> 00:03:26,520
I'm going to paste those things that I got from thought.

46
00:03:26,570 --> 00:03:26,780
All right.

47
00:03:26,780 --> 00:03:33,680
So just like thought we have some of the same things we have usually same time stamp and some text.

48
00:03:33,680 --> 00:03:39,810
We're going to delete these three because we don't have any of that and I'm going to change this thought

49
00:03:39,830 --> 00:03:42,820
text to comment text.

50
00:03:43,010 --> 00:03:43,620
OK.

51
00:03:43,910 --> 00:03:48,940
And then in our initialiser here I'm going to delete these three here.

52
00:03:48,940 --> 00:03:55,850
I'm going to change comment text here to common text here and common text here.

53
00:03:56,090 --> 00:03:58,880
And this is also going to be common text.

54
00:03:58,960 --> 00:04:05,510
I'm going to delete the last three items in our initialiser and there we go.

55
00:04:05,930 --> 00:04:09,140
Our parse data function is going to be also very similar.

56
00:04:09,140 --> 00:04:16,170
So I'm going to need to import firebase and that looks good.

57
00:04:16,220 --> 00:04:23,000
I'm actually going to just comment all of this out for now and we'll come back to that in a lesson or

58
00:04:23,030 --> 00:04:23,600
two.

59
00:04:23,810 --> 00:04:24,860
All right.

60
00:04:24,880 --> 00:04:28,280
I'm going to save that up looks like it wants returns.

61
00:04:28,280 --> 00:04:31,510
I want to comment out the entire function.

62
00:04:31,510 --> 00:04:32,750
There we go.

63
00:04:32,760 --> 00:04:36,210
I can save that and we'll come back to this function here in a lesson or two.

64
00:04:36,230 --> 00:04:40,070
But for now this is all we need for our comment.

65
00:04:40,150 --> 00:04:41,770
And just to run over this one more time.

66
00:04:41,870 --> 00:04:47,370
We have private variables of username time stamp and the comment text.

67
00:04:47,480 --> 00:04:53,110
Then we have our initialiser here using timestep in comment text and that's it pretty simple.

68
00:04:53,150 --> 00:04:59,570
Just a simple class and it's initialiser and then we're going to jump back into our comments Visi and

69
00:04:59,580 --> 00:05:08,560
let's go in and create a variable called comments and this is going to be equal to an array of comment

70
00:05:08,780 --> 00:05:14,790
and we will initialize it to an empty array and then down here in our number of rows in S..

71
00:05:14,790 --> 00:05:21,260
Now instead of returning 0 we can actually return comments that count.

72
00:05:21,830 --> 00:05:27,240
And here in our cell for row function we can say if let.

73
00:05:27,340 --> 00:05:30,910
So it's equal to table view.

74
00:05:31,260 --> 00:05:38,290
And we're going to Q Celso the Q reuseable cell with identifier of string for index path.

75
00:05:38,510 --> 00:05:40,980
And they didn't find we actually haven't said yet.

76
00:05:41,150 --> 00:05:49,820
So we need to jump back into our storyboard select our comment cell here and in our attributes and Specter

77
00:05:49,830 --> 00:05:57,830
said a reuse identifier we'll just say comment cell Kate going to copy that and jump back in the comments

78
00:05:57,830 --> 00:05:58,700
of the C.

79
00:05:58,850 --> 00:06:01,140
And that's what this identifier right here is.

80
00:06:01,150 --> 00:06:08,630
So when I say comment sell for index path and the index path is index path that grow.

81
00:06:08,930 --> 00:06:17,720
OK so if let's sell and we're going to cast it as a comment cell and then what are we going to do with

82
00:06:17,720 --> 00:06:25,700
this so that we just created to what's going on here and it's path index path that we're just just index

83
00:06:25,700 --> 00:06:26,400
path.

84
00:06:26,780 --> 00:06:27,040
All right.

85
00:06:27,050 --> 00:06:34,100
And so now what do we do with this cell we say cell and we need to add a function in our comments cell

86
00:06:34,100 --> 00:06:35,250
to configure it.

87
00:06:35,480 --> 00:06:36,810
So let's go and do that real quick.

88
00:06:36,980 --> 00:06:44,810
So here in our comments cell we were going to create a function called configure cell just like we usually

89
00:06:44,810 --> 00:06:45,450
do.

90
00:06:45,830 --> 00:06:47,500
And we're going to pass into it.

91
00:06:50,200 --> 00:06:56,240
And see here it looks like I missed a closing curly brace.

92
00:06:56,240 --> 00:06:56,960
There we go.

93
00:06:56,960 --> 00:07:05,960
Configure cell and we're going to pass into this a comment type comment and we're just going to set

94
00:07:05,960 --> 00:07:07,190
these variables right here.

95
00:07:07,200 --> 00:07:07,620
Right.

96
00:07:07,790 --> 00:07:10,970
So user name is username.

97
00:07:10,960 --> 00:07:22,880
Text that text is equal to going to say home and that is passed into it that username and then the comment

98
00:07:24,050 --> 00:07:31,040
text that text is equal to comment dot comment text.

99
00:07:31,640 --> 00:07:37,430
And then when you have a date here and let's go ahead and write the code for that.

100
00:07:37,490 --> 00:07:42,020
We're going to need a form letter so this is just like what we did in our thought so here.

101
00:07:42,490 --> 00:07:47,470
In fact I'm just going to copy this code that we have here and paste it in our comment.

102
00:07:47,600 --> 00:07:50,900
So here and just modify it as needed.

103
00:07:50,910 --> 00:07:52,910
Let's see here for a matter.

104
00:07:52,910 --> 00:07:53,810
Time stamp.

105
00:07:53,890 --> 00:08:04,250
So this should be comment time stamp and this should be calm and text that text equals time stamp.

106
00:08:04,320 --> 00:08:05,270
I'm going to save that.

107
00:08:05,300 --> 00:08:07,410
And that looks good.

108
00:08:07,410 --> 00:08:12,260
And we're not using our awake from NIB at all so I'm just going to delete that.

109
00:08:12,870 --> 00:08:14,500
And that was good.

110
00:08:14,510 --> 00:08:17,590
All right let's jump back to our comments of PC-DOS Swift.

111
00:08:18,050 --> 00:08:23,660
And now that we have our configure function we can say cell that to configure our cell and we're going

112
00:08:23,660 --> 00:08:24,740
to pass into it.

113
00:08:24,950 --> 00:08:31,760
The comment that corresponds to this index path Rowse when I say comments and we're going to grab out

114
00:08:31,760 --> 00:08:39,410
of the array Commines index dot row and then we're going to return.

115
00:08:39,860 --> 00:08:42,740
So that looks good.

116
00:08:42,950 --> 00:08:50,240
And if for some reason we are not able to teach you a cell then we'll just return a generic table view

117
00:08:50,240 --> 00:08:51,390
so.

118
00:08:52,070 --> 00:08:52,400
All right.

119
00:08:52,400 --> 00:08:58,910
And I think we're going to call this video good in the next lesson we are going to add our first comment

120
00:08:59,180 --> 00:09:04,290
and learn about a new fire store technique that we haven't used yet called transactions.

121
00:09:04,290 --> 00:09:04,770
All right.

122
00:09:04,910 --> 00:09:07,870
So I hope you're excited for that and I'll see you in the next one.
