1
00:00:05,920 --> 00:00:07,000
A what's up everyone.

2
00:00:07,010 --> 00:00:11,710
Mark Price here at the slopes dot com and we're making fantastic progress on our application here.

3
00:00:11,720 --> 00:00:12,990
Coder's way up.

4
00:00:13,590 --> 00:00:17,370
And what we need to do now is actually feed it with data.

5
00:00:17,370 --> 00:00:24,020
Now like I said normally you would have an application hit the Internet a server and Dellis and have

6
00:00:24,040 --> 00:00:24,300
data.

7
00:00:24,300 --> 00:00:25,620
We don't have a server right now.

8
00:00:25,990 --> 00:00:29,270
But on the flip on the opposite side some apps don't actually do that.

9
00:00:29,280 --> 00:00:33,160
They actually have the data hardcoded with the app because there's a limited data set.

10
00:00:33,270 --> 00:00:35,600
Or maybe they don't have a server and they're just doing a few limited things.

11
00:00:35,600 --> 00:00:41,160
This might be like let's say you're building an app for a law firm or an app for a local business where

12
00:00:41,160 --> 00:00:43,820
they only have so much data and they're not going to probably update it a lot.

13
00:00:43,860 --> 00:00:45,870
Well that's our case right now.

14
00:00:45,920 --> 00:00:47,980
And so we're actually going to build the data in the app.

15
00:00:48,000 --> 00:00:49,090
There's nothing wrong with that.

16
00:00:49,110 --> 00:00:52,710
It wouldn't probably be the reality of what you're doing because you're you're probably talking to a

17
00:00:52,710 --> 00:00:56,850
server when you're building up a storefront but we're going to build that our data model just like as

18
00:00:56,850 --> 00:01:00,750
if we're downloading it from the Internet and we're going to do it here in the app and that's what we

19
00:01:00,750 --> 00:01:04,790
might actually do for if you're running an app for a local business that doesn't need continuous data.

20
00:01:04,790 --> 00:01:07,080
So it's a win win all around.

21
00:01:07,080 --> 00:01:11,400
So let's go back to our going to stop it from running this to make the computer run a little bit faster

22
00:01:11,400 --> 00:01:12,140
here.

23
00:01:12,300 --> 00:01:16,480
And so we know it's running but we also know that it's not feeding data from where it needs to go.

24
00:01:16,530 --> 00:01:20,700
And so I already know that we're going to need some type of model soon to be a reusable class or struct

25
00:01:21,120 --> 00:01:24,330
that can feed our table with data.

26
00:01:24,450 --> 00:01:27,190
So let's go ahead and create a new folder here.

27
00:01:28,590 --> 00:01:32,200
Next it will before we do that let's create the model itself so I'm going to go to the model folder

28
00:01:32,260 --> 00:01:33,950
in a new file.

29
00:01:33,950 --> 00:01:36,310
Inside this model file We're going to swap file.

30
00:01:37,160 --> 00:01:39,610
And what we're going to do is we're going to call this a category.

31
00:01:39,770 --> 00:01:42,800
So basically I'm creating a category that's a reusable struct.

32
00:01:42,800 --> 00:01:44,840
In our case we'll use a struct.

33
00:01:45,140 --> 00:01:46,050
OK.

34
00:01:46,410 --> 00:01:47,340
This looks good to me.

35
00:01:47,340 --> 00:01:50,950
And so we're going to say structure and we're going to call this category.

36
00:01:51,500 --> 00:01:59,930
And what we're going to do is we're going to create a couple of variables one for the variable for the

37
00:02:00,860 --> 00:02:05,570
title and a variable for the image the name of the image that's in our that's in our assets folder right

38
00:02:05,570 --> 00:02:05,780
here.

39
00:02:05,780 --> 00:02:06,380
OK.

40
00:02:06,440 --> 00:02:11,330
We need to grab these names we need to feed those into the table so the image of you knows which file

41
00:02:11,330 --> 00:02:12,030
to grab.

42
00:02:12,130 --> 00:02:12,470
OK.

43
00:02:12,480 --> 00:02:16,130
And so we're going to create an array of categories that stores that information.

44
00:02:16,160 --> 00:02:16,560
OK.

45
00:02:16,610 --> 00:02:20,810
This is exactly what you would do if you were downloading data from a server and then parsing it you

46
00:02:20,810 --> 00:02:26,000
would create some type of model or class that can be recreated over and over and store that data.

47
00:02:26,040 --> 00:02:26,470
OK.

48
00:02:27,790 --> 00:02:36,820
So first things first is let's go ahead and create our title in our image name so public var title of

49
00:02:36,970 --> 00:02:37,660
type string.

50
00:02:37,660 --> 00:02:39,630
In fact let's be more explicit.

51
00:02:40,090 --> 00:02:43,000
Well look here's another Here's another topic of discussion.

52
00:02:43,100 --> 00:02:44,670
We can say category title right.

53
00:02:44,980 --> 00:02:52,240
But maybe that's a little too explicit because the struct itself is already category so we know we know

54
00:02:52,240 --> 00:02:57,310
that the if we said just the title that it's the category title since we already are named it category.

55
00:02:57,310 --> 00:02:58,490
Why repeat yourself right.

56
00:02:58,660 --> 00:03:01,590
So I think it's ok actually in this case to just say title.

57
00:03:01,630 --> 00:03:02,260
All right.

58
00:03:02,370 --> 00:03:06,970
So we of type string and we're not going to make it an optional or implicitly enwrapped optional we're

59
00:03:06,970 --> 00:03:11,080
going to make sure the data is there when it's initialized so we're going to leave it like so.

60
00:03:11,440 --> 00:03:17,100
And then as soon as the public bar image name and this would be of type string as well.

61
00:03:17,810 --> 00:03:18,140
OK.

62
00:03:18,160 --> 00:03:20,320
But I think there's a problem here.

63
00:03:20,590 --> 00:03:23,170
I don't think it's good practice to keep these public.

64
00:03:23,350 --> 00:03:26,060
OK to just let anybody set these things.

65
00:03:26,140 --> 00:03:26,470
OK.

66
00:03:26,500 --> 00:03:34,090
Well what I'm saying is you know if we create a category if I was to create a category like this and

67
00:03:34,260 --> 00:03:39,760
this is public titles here and let's just print now just for sake of demonstration I'm putting the exclamation

68
00:03:39,760 --> 00:03:44,200
marks there and if I was to go into categories ABC and let's say I wanted to create a category so I

69
00:03:44,200 --> 00:03:47,350
said let equal equals category.

70
00:03:47,800 --> 00:03:55,360
So look at the legacy cat that tidal pools Glock OK that's typically not a good practice.

71
00:03:55,360 --> 00:03:58,730
You don't want to be able to just set public variables for anywhere.

72
00:03:58,780 --> 00:04:03,840
And the reason why is because you want to control the data that's in your class.

73
00:04:03,850 --> 00:04:06,480
You want to you are the creator of that class or that struck.

74
00:04:06,490 --> 00:04:11,650
You want to control how it's accessed because you don't want anybody shoving junk data into here.

75
00:04:11,780 --> 00:04:14,990
OK and it's probably hard to understand right now but that's OK.

76
00:04:15,010 --> 00:04:18,130
Just take my word for it that we want to protect our data a little bit better.

77
00:04:18,130 --> 00:04:20,960
So what I'm going to do is delete these examples here.

78
00:04:21,070 --> 00:04:25,960
What I'm going to do is go back to my category and instead of making these public what I want to do

79
00:04:26,170 --> 00:04:34,690
is say private sit on these here private and say and what this means is I will no longer be able to

80
00:04:34,690 --> 00:04:37,500
set these variables for other classes OK.

81
00:04:37,820 --> 00:04:42,850
From a view control or things like that I can retrieve them and use them but I can't set them and I

82
00:04:42,850 --> 00:04:45,730
think that gives me better control of the data that's in here.

83
00:04:45,730 --> 00:04:49,600
I don't want any you know let's say your buddy who's a programmer comes in the app and doesn't know

84
00:04:49,600 --> 00:04:54,130
what he's doing and start setting the wrong titles and hear things like that and you can't really control

85
00:04:54,130 --> 00:04:54,380
it.

86
00:04:54,550 --> 00:05:01,120
But if you design your struct or your class in a way that that serves your application the way that

87
00:05:01,120 --> 00:05:05,710
you wanted to protect it then you can be sure that it's it's acting as needed.

88
00:05:05,740 --> 00:05:11,620
And again you don't have the complete understanding here but the rule of thumb here is you want public

89
00:05:11,620 --> 00:05:16,900
variables that can be fetched but you don't want them typically to be set by outside classes unless

90
00:05:16,900 --> 00:05:18,180
that's what your app calls for.

91
00:05:18,280 --> 00:05:18,930
OK.

92
00:05:19,210 --> 00:05:22,390
So what we're going to do is create an initializer here.

93
00:05:22,420 --> 00:05:25,600
All right we have the title the image name.

94
00:05:25,600 --> 00:05:27,270
Now these are parameter names.

95
00:05:27,310 --> 00:05:27,900
OK.

96
00:05:28,060 --> 00:05:32,260
You typically name initialiser parameter names the same as this is this variable the same as this.

97
00:05:32,260 --> 00:05:34,020
Absolutely not.

98
00:05:34,120 --> 00:05:38,620
We're going to pass data in and then even though it has the same name we're going to set it up here

99
00:05:38,620 --> 00:05:39,540
to this title here.

100
00:05:39,550 --> 00:05:43,540
It's just a good convention to make these the same names as the variables that you want to set in your

101
00:05:43,540 --> 00:05:45,040
initializer.

102
00:05:45,040 --> 00:05:51,870
And so we're going to say self-direct title was title and self-doubt image name equals image name.

103
00:05:52,070 --> 00:05:56,620
OK so all we've done so far is we've created a struct called category.

104
00:05:56,740 --> 00:06:02,770
We created a couple of variables that are public for fetching forgetting but they're private for setting

105
00:06:02,860 --> 00:06:06,150
LCI classes and etc. can't set them.

106
00:06:06,220 --> 00:06:10,630
However when you're creating it from the beginning when you create a new category that's when you can

107
00:06:10,630 --> 00:06:12,210
pass the data into these variables here.

108
00:06:12,220 --> 00:06:16,480
And we are in complete control of how data is getting into our struct here.

109
00:06:16,570 --> 00:06:22,650
And so we're seeing self-doubt title self of course is referring to this this class or struct itself.

110
00:06:22,780 --> 00:06:23,300
OK.

111
00:06:23,390 --> 00:06:27,640
So we're saying this title here is going to be equal to the one that we're just passing in and this

112
00:06:27,640 --> 00:06:30,940
image name here is going to be equal to the one that we're passing in.

113
00:06:31,440 --> 00:06:37,210
OK so now we've got our our category struct and a little bit data here a little bit of data protection

114
00:06:37,210 --> 00:06:38,370
which is great.

115
00:06:38,530 --> 00:06:43,390
And so what we're going to do when we're going to say is just from now on even if you don't understand

116
00:06:44,230 --> 00:06:45,130
just do it this way.

117
00:06:45,280 --> 00:06:45,710
OK.

118
00:06:45,850 --> 00:06:50,950
Make it private for setting and public for retrieving and it'll save you a lot of headaches down the

119
00:06:50,950 --> 00:06:53,910
road if you don't make it public all together that's fine.

120
00:06:53,920 --> 00:06:55,400
But I just wouldn't recommend it.

121
00:06:55,620 --> 00:06:57,580
And can we do this in our apps.

122
00:06:57,580 --> 00:07:03,900
So next thing is we've got this data here but how do we actually create a list of data list of data

123
00:07:03,910 --> 00:07:05,740
to feed our table view with.

124
00:07:05,740 --> 00:07:09,040
And we don't have that right now so what we're going to do is we're going to create what's called a

125
00:07:09,040 --> 00:07:13,170
Service OK and a service is a design paradigm in programming.

126
00:07:13,270 --> 00:07:17,300
It can perform functions for you or provide a service.

127
00:07:17,300 --> 00:07:18,630
It is what you think it is.

128
00:07:18,880 --> 00:07:24,250
And you know similar to you might call a plumber service or an electrician service they'll come and

129
00:07:24,250 --> 00:07:29,250
do service for you you don't own it you know you don't you just ask them to do something and they do

130
00:07:29,250 --> 00:07:30,890
it for you over and over again.

131
00:07:31,050 --> 00:07:35,970
And that's the same thing that we're doing here was a category you create multiple copies of a category

132
00:07:35,990 --> 00:07:40,920
OK you're creating something over and over and over again whereas a service does things for you.

133
00:07:41,610 --> 00:07:46,320
And so our service is going to store some data and it's going to perform it's going to send us the data

134
00:07:46,320 --> 00:07:47,500
that we need more or less.

135
00:07:47,650 --> 00:07:54,390
So a new folder our new group we're going to call this Services I'm going to put a new file in here

136
00:07:55,570 --> 00:08:02,030
and it's just going to be a swift file and I'm going to call this data service OK.

137
00:08:02,490 --> 00:08:09,730
And what we're going to do is we're making a class music class data service like so and then we're going

138
00:08:09,730 --> 00:08:18,500
to say static let instance equals when say data service.

139
00:08:18,650 --> 00:08:25,050
OK so this might be confusing to you but what we've just done here is the key term to remember what

140
00:08:25,050 --> 00:08:27,190
we've just done is we've created a singleton.

141
00:08:27,210 --> 00:08:28,950
Singleton is another design pattern.

142
00:08:29,280 --> 00:08:31,830
And this is the this is the idea behind it.

143
00:08:31,920 --> 00:08:36,870
So you know the class or struct that's how you would typically use it is you would create multiple copies

144
00:08:36,870 --> 00:08:38,220
of it over and over and over again.

145
00:08:38,220 --> 00:08:45,310
Well what we've done is we've created a variable here ok called instance that's what we've called it.

146
00:08:45,660 --> 00:08:47,130
It's a constant actually.

147
00:08:47,130 --> 00:08:49,950
And we've created a brand new copy of the data service.

148
00:08:49,980 --> 00:08:50,960
But guess what.

149
00:08:51,000 --> 00:08:52,770
We've made it static.

150
00:08:52,890 --> 00:08:53,470
OK.

151
00:08:53,670 --> 00:08:59,490
And what static does is it means there's only ever one copy in memory so you can only ever ever ever

152
00:08:59,850 --> 00:09:01,250
create one data service.

153
00:09:01,320 --> 00:09:02,000
OK.

154
00:09:02,130 --> 00:09:03,060
And that's what we want we want.

155
00:09:03,060 --> 00:09:05,510
One copy in memory because this is going to hold our data for the app.

156
00:09:05,520 --> 00:09:09,230
You wouldn't want 10 different copies of data service all holding different versions of the data.

157
00:09:09,270 --> 00:09:10,640
Otherwise your app would be broken.

158
00:09:10,650 --> 00:09:13,540
It would have inconsistent data and bad user experience.

159
00:09:13,740 --> 00:09:20,150
And so by specifying a constant here called instance and then immediately initializing a new class a

160
00:09:20,150 --> 00:09:21,000
data service.

161
00:09:21,210 --> 00:09:26,370
Every time we go in and grab this instance it's going to refer to the exact same object in memory which

162
00:09:26,370 --> 00:09:27,730
is what we want.

163
00:09:27,750 --> 00:09:32,280
Again you don't have to completely understand this but typically when you write a service you need to

164
00:09:32,280 --> 00:09:34,540
do something for you over and over again.

165
00:09:34,560 --> 00:09:36,340
You can make it a singleton.

166
00:09:36,360 --> 00:09:41,610
The caveat with singletons is it's there's one copy in memory so if we create this in memory from the

167
00:09:41,610 --> 00:09:45,690
beginning of our app OK it's probably going to be there for the entire life lifetime of the app.

168
00:09:45,690 --> 00:09:48,170
So if you need to save memory.

169
00:09:48,240 --> 00:09:48,760
OK.

170
00:09:48,900 --> 00:09:54,270
You don't want to have a bunch like 100 different singleton classes doing 100 different things.

171
00:09:54,290 --> 00:09:58,920
OK because your app is starting to take a memory that will never be reclaimed because there's always

172
00:09:58,920 --> 00:10:03,240
one in memory whereas when you create objects and strokes you know those things get cleaned up when

173
00:10:03,240 --> 00:10:04,240
they're not being used anymore.

174
00:10:04,260 --> 00:10:09,650
This will stay for as long as your app is living unless you manually destroyed it somehow.

175
00:10:09,810 --> 00:10:16,500
So I know that's a bit wordy and there's a lot to go over there but we've just created our instance

176
00:10:16,500 --> 00:10:16,890
here.

177
00:10:16,980 --> 00:10:24,480
And what I want to do is I want to envision that work table is calling a function that's hitting a server

178
00:10:24,810 --> 00:10:25,740
and it's retrieving data.

179
00:10:25,740 --> 00:10:27,160
Now in our case it's not going to do that.

180
00:10:27,170 --> 00:10:28,230
We're going to simulate that.

181
00:10:28,230 --> 00:10:33,450
So I might have a function here called Get categories and we'd go to the server.

182
00:10:33,630 --> 00:10:34,240
OK.

183
00:10:34,530 --> 00:10:39,460
And we will return a we would get a list of categories and then feed them into our app.

184
00:10:39,520 --> 00:10:44,580
And so let's go ahead and actually create that data source let's say that this is our data source from

185
00:10:44,580 --> 00:10:48,060
the server so private let categories.

186
00:10:48,750 --> 00:10:52,250
And we're going to create an array filled with data in it.

187
00:10:52,290 --> 00:11:00,840
So we're going to do is we're going to create a category and knows how it needs a title and an image.

188
00:11:01,060 --> 00:11:07,950
OK so what we're going to do is we're going to pass in a title so we'll say shirts and the image name

189
00:11:08,520 --> 00:11:15,600
is going to be shirts stuck PND but a comma here because we're just we pretty populating an array with

190
00:11:15,600 --> 00:11:16,190
data.

191
00:11:16,410 --> 00:11:19,730
So the next item in the array we're going to create a new category.

192
00:11:20,250 --> 00:11:23,730
And again you're starting to see multiple copies of an object.

193
00:11:23,730 --> 00:11:28,980
So right now these two categories it's going to create two copies of this struct and it's going to hold

194
00:11:28,980 --> 00:11:30,270
them in different places in memory.

195
00:11:30,360 --> 00:11:30,710
OK.

196
00:11:30,720 --> 00:11:32,760
Whereas the singleton only has one.

197
00:11:33,150 --> 00:11:34,270
That's the difference OK.

198
00:11:34,290 --> 00:11:38,560
In one case we're creating something in another case we're using a service over and over again.

199
00:11:38,910 --> 00:11:42,990
So these image name could is that PMG.

200
00:11:43,040 --> 00:11:46,490
Now again if you're confused like Mark how is this real use case again.

201
00:11:46,500 --> 00:11:51,810
Well if you have an app where you want to go to all your data in the app let's say you're a new developer

202
00:11:51,810 --> 00:11:55,830
and you have an idea you're not ready to talk to a server yet or your app small enough you can actually

203
00:11:55,830 --> 00:11:57,000
do something just like this.

204
00:11:57,030 --> 00:12:01,860
You can put all your data here in the app and feed it into your table use things like that.

205
00:12:02,250 --> 00:12:07,060
If if you weren't doing it locally you want to hit a server.

206
00:12:07,160 --> 00:12:11,040
Ok you might still do something just like this you'd hold an array but instead of creating them here

207
00:12:11,070 --> 00:12:15,990
at run at initialization time it would come from the server and then it would populate the array.

208
00:12:16,050 --> 00:12:19,750
You know we would say a category's equals and the new array from the server.

209
00:12:19,770 --> 00:12:26,030
So not all that different category title.

210
00:12:26,160 --> 00:12:29,920
And this is going to be hat's image name as hats PND.

211
00:12:29,940 --> 00:12:34,980
Now I know these these are the right image names because I dragged them in and as you can see we've

212
00:12:34,980 --> 00:12:39,170
got digital hats and those are PNB files OK.

213
00:12:40,020 --> 00:12:47,180
And when you get a category title and we're going to say digital and image name is going to be digital

214
00:12:47,200 --> 00:12:54,230
that PMG like so OK so now we have a list of categories this is great.

215
00:12:54,450 --> 00:13:01,110
And what we've done here is we've inferred the type of the Saray what we're seeing as categories is

216
00:13:01,110 --> 00:13:04,080
an array of type category.

217
00:13:04,210 --> 00:13:04,760
Okay.

218
00:13:04,830 --> 00:13:13,110
So when I say return cat or good categories the return type is going to be an array of type category

219
00:13:13,350 --> 00:13:14,420
like so.

220
00:13:14,860 --> 00:13:15,110
OK.

221
00:13:15,110 --> 00:13:20,340
So what we're saying is that we're going to return to ever calls of function and array of categories.

222
00:13:20,490 --> 00:13:21,110
Okay.

223
00:13:21,130 --> 00:13:24,850
With the official category struct and this is not accessible.

224
00:13:24,850 --> 00:13:30,550
We made it private because we don't want anybody accessing that data directly we want a function here

225
00:13:30,820 --> 00:13:34,000
in case it needed to do any cleanup or manipulation.

226
00:13:34,060 --> 00:13:38,620
But what's really happening here is you know we're simulating we're hitting a server and we're turning

227
00:13:38,620 --> 00:13:38,920
data.

228
00:13:38,920 --> 00:13:44,870
And you would do that through a function and then we're going to do in here is return category.

229
00:13:45,310 --> 00:13:47,990
So we're going to return this array to whoever calls it.

230
00:13:48,160 --> 00:13:50,180
And because this array is a type category.

231
00:13:50,440 --> 00:13:54,600
This will go away and we are in business here.

232
00:13:54,780 --> 00:13:55,630
Okay.

233
00:13:56,200 --> 00:13:57,120
So a lot to cover right.

234
00:13:57,130 --> 00:14:02,440
It's a lot of information but our app is really coming together it's looking nice we get some good data

235
00:14:02,440 --> 00:14:02,950
in here.

236
00:14:03,250 --> 00:14:07,330
And of course this is the importance of working with structure clauses that you can make reusable objects.

237
00:14:07,360 --> 00:14:11,500
You write the code once and then you can use it over and over and over again.

238
00:14:11,620 --> 00:14:12,140
OK.

239
00:14:12,430 --> 00:14:17,200
So hear in our view controller we've got a table view.

240
00:14:17,320 --> 00:14:17,810
OK.

241
00:14:17,990 --> 00:14:20,540
But the table is not being fed with data yet.

242
00:14:20,810 --> 00:14:28,220
So in order to get this working properly we need to introduce something called protocols and delegates

243
00:14:28,790 --> 00:14:31,210
done that new words new things.

244
00:14:31,220 --> 00:14:34,100
No my head's going to explode already Mark just make it stop.

245
00:14:34,100 --> 00:14:34,860
Sorry.

246
00:14:35,230 --> 00:14:38,660
You're on an adventure of brain explosion and it's going to keep going until the end of this course

247
00:14:38,840 --> 00:14:40,210
and for the rest of your life as a programmer.

248
00:14:40,220 --> 00:14:41,910
Sorry.

249
00:14:42,360 --> 00:14:42,710
OK.

250
00:14:42,740 --> 00:14:44,430
So we got a tape of you how do we feel with Dave.

251
00:14:44,450 --> 00:14:47,990
Well a table view it needs to know where the data sources.

252
00:14:47,990 --> 00:14:49,610
Hey I need some data.

253
00:14:49,640 --> 00:14:50,840
Give it to me where do I get it.

254
00:14:50,840 --> 00:14:55,670
And also there's other things too it's like hey I need to show cells on the screen I need to show something

255
00:14:55,670 --> 00:15:01,080
on the screen and fill it with data so you know the user can have something to look at.

256
00:15:01,240 --> 00:15:02,170
It's not doing there now.

257
00:15:02,210 --> 00:15:08,330
So let's go ahead and do that and we do that by implementing some protocols put a comma after you and

258
00:15:08,330 --> 00:15:14,150
your controller or type in your table you data source and you table you delegate.

259
00:15:14,410 --> 00:15:15,080
OK.

260
00:15:15,650 --> 00:15:16,750
These are two protocols.

261
00:15:16,760 --> 00:15:23,420
And even though it says data source and so delegate these are protocols a swift protocol and they're

262
00:15:23,420 --> 00:15:29,690
really based actually on objective c code it was written long ago but in swift they're translated as

263
00:15:29,690 --> 00:15:30,200
protocols.

264
00:15:30,200 --> 00:15:34,670
And so these are protocols and swithe And what we're saying is we're going to abide by a set of rules

265
00:15:34,670 --> 00:15:37,520
and we'll talk more about protocols later in more depth and detail.

266
00:15:37,520 --> 00:15:39,070
So just follow along for now.

267
00:15:39,260 --> 00:15:44,570
So I table the datasource in table view delegate someone to save this file here.

268
00:15:44,600 --> 00:15:45,360
All right.

269
00:15:45,440 --> 00:15:47,650
And normally these would yell at me.

270
00:15:47,660 --> 00:15:48,010
All right.

271
00:15:48,020 --> 00:15:48,740
Here we go.

272
00:15:49,050 --> 00:15:53,720
And so if he clicked this little red icon here new with X code 9 is actually populate the functions

273
00:15:53,720 --> 00:15:55,640
that you need to get this working.

274
00:15:55,640 --> 00:15:58,460
So click that little red air and it says type categories.

275
00:15:58,470 --> 00:16:00,930
VC does not conform to protocol.

276
00:16:00,950 --> 00:16:02,100
You idea will be datasource.

277
00:16:02,140 --> 00:16:08,010
You want to add protocol stubs so what is saying is you're not listening to the rules.

278
00:16:08,020 --> 00:16:13,780
You adopted a set of rules you table your data source and you table the delegate but you're not abiding

279
00:16:13,780 --> 00:16:16,210
by the rules you haven't even implemented them yet.

280
00:16:16,210 --> 00:16:21,300
So when you click fix just great and it put them up here which is kind of annoying.

281
00:16:21,310 --> 00:16:23,510
So I command x.

282
00:16:24,280 --> 00:16:28,190
And what we're going to do is put them down here and we're going to do some cleanup here.

283
00:16:28,540 --> 00:16:30,890
As of the current X code version which is beta.

284
00:16:31,000 --> 00:16:35,110
It shows you know this available etc. etc. that may go away in future versions.

285
00:16:35,110 --> 00:16:37,610
I would expect it would cause it's kind of messy and ugly.

286
00:16:37,630 --> 00:16:41,560
But get rid of the available as well too and it's available here.

287
00:16:41,980 --> 00:16:47,280
So it's implemented the two functions that it requires in order to operate correctly.

288
00:16:47,630 --> 00:16:47,910
OK.

289
00:16:47,920 --> 00:16:49,100
Number of ROSETT sections.

290
00:16:49,120 --> 00:16:53,890
How many rows do you want the table view to show it needs to know that in advance and then sell FERO

291
00:16:53,890 --> 00:16:54,830
index path.

292
00:16:54,980 --> 00:16:58,420
OK self self-growth at index path.

293
00:16:58,420 --> 00:17:02,690
And what this is saying is hey let's create a cell a reusable cell.

294
00:17:02,830 --> 00:17:07,840
At this particular path so item number 10 showed the cell and put this type of data this is where you

295
00:17:07,840 --> 00:17:13,820
actually feed the data into Table View item number one or two or three or four etc..

296
00:17:14,230 --> 00:17:16,440
Ok so how many rows are in the section.

297
00:17:16,690 --> 00:17:18,120
Well this is pretty easy.

298
00:17:18,130 --> 00:17:20,010
All we have to do it wants an integer.

299
00:17:20,080 --> 00:17:25,450
And we just want to know how many table view rows we already know that it's what four we have four on

300
00:17:25,450 --> 00:17:26,350
the screen.

301
00:17:26,350 --> 00:17:27,820
Now it could just be returned for.

302
00:17:27,930 --> 00:17:30,170
That's cheating and that's not the way that you would write code.

303
00:17:30,220 --> 00:17:31,630
Real code robust code.

304
00:17:31,750 --> 00:17:37,700
So we're going to return data service that instance we're going to call that instance function on it

305
00:17:38,410 --> 00:17:43,640
or that variable and then we're going to call the function get categories.

306
00:17:43,880 --> 00:17:44,220
OK.

307
00:17:44,230 --> 00:17:45,930
So what we're doing is we're grabbing the categories.

308
00:17:45,940 --> 00:17:48,010
Well what is category's returnable.

309
00:17:48,010 --> 00:17:51,810
It returns an array so we know that we're getting an array right here.

310
00:17:51,940 --> 00:17:53,140
Well this is asking for an inch.

311
00:17:53,140 --> 00:17:55,750
So how do we get the total number of items in an array.

312
00:17:55,780 --> 00:17:57,010
Simple.

313
00:17:57,010 --> 00:17:58,910
Calling the doc count function.

314
00:17:59,290 --> 00:17:59,640
OK.

315
00:17:59,650 --> 00:18:05,520
So what we're doing here is we're saying return the total number of items in this array.

316
00:18:05,680 --> 00:18:06,180
Okay.

317
00:18:06,250 --> 00:18:07,390
Easy enough.

318
00:18:07,390 --> 00:18:09,510
That's all we're doing we're turning a count.

319
00:18:09,570 --> 00:18:10,570
What about this guy.

320
00:18:10,660 --> 00:18:14,350
How do we actually grab a cell and put data in it.

321
00:18:14,770 --> 00:18:20,650
Well I think we should write some code in our table cell first before we actually implement this function

322
00:18:20,650 --> 00:18:20,800
here.

323
00:18:20,800 --> 00:18:26,260
So what we're going to do is we're going to go over here to our view or category sell what I want to

324
00:18:26,260 --> 00:18:30,490
do is delete this function sets like they don't need this and I don't need this away from the zip file

325
00:18:30,490 --> 00:18:31,920
or in the file right here.

326
00:18:32,020 --> 00:18:33,450
We're going to create our own function here.

327
00:18:33,690 --> 00:18:36,990
Or to call this update view.

328
00:18:37,180 --> 00:18:37,560
OK.

329
00:18:37,660 --> 00:18:43,000
Basically update the views on the cell and we're going to pass in that category whatever the current

330
00:18:43,000 --> 00:18:44,570
category is.

331
00:18:45,010 --> 00:18:45,850
Okay.

332
00:18:45,850 --> 00:18:48,970
And again this is another reason why you should have reusable things.

333
00:18:48,970 --> 00:18:52,870
Otherwise we'd have to have a title here and image name here and we'd be passing two different items

334
00:18:52,870 --> 00:18:57,570
and over and over again or in this case we're only passing one reusable object which is well-written

335
00:18:57,580 --> 00:18:59,260
code and protected.

336
00:18:59,260 --> 00:19:02,850
So we're an updated use basically every time we want to show a cell on the screen.

337
00:19:02,890 --> 00:19:07,540
We're going to call this a dubious function and pass in a category and it's going to update the views.

338
00:19:07,540 --> 00:19:10,680
So let's show you how easy this is here.

339
00:19:10,780 --> 00:19:11,260
OK.

340
00:19:11,350 --> 00:19:15,670
So we're going to say category image.

341
00:19:15,950 --> 00:19:22,600
That image is going to set the image on it equals you image and we're going to do the one that says

342
00:19:22,690 --> 00:19:29,180
image named and all we're going to do is pass in the name of the image that we set in the category category

343
00:19:29,610 --> 00:19:30,930
to image name.

344
00:19:30,970 --> 00:19:35,150
It's that easy category inch or category title.

345
00:19:35,170 --> 00:19:41,610
The next one text equals category Dopp title.

346
00:19:41,650 --> 00:19:44,430
We did that as well to remember our category here.

347
00:19:44,440 --> 00:19:46,030
It has an image name and it has a title.

348
00:19:46,030 --> 00:19:47,160
Amazing.

349
00:19:47,170 --> 00:19:48,430
Amazing.

350
00:19:48,430 --> 00:19:53,850
All we have to do is grab what we've already set right here and it's as simple as that.

351
00:19:53,850 --> 00:19:56,230
We're going to update the views every single time.

352
00:19:56,260 --> 00:19:57,580
Easy peasy.

353
00:19:57,700 --> 00:20:03,010
OK so let's go back to our categories and see now and how we can implement this function down here.

354
00:20:03,040 --> 00:20:05,870
Let we give it a little more space so you can see what we're working on here.

355
00:20:06,160 --> 00:20:07,330
Let's close this.

356
00:20:07,330 --> 00:20:15,550
So here in our table view what we're going to do is say if let cell Trenck create a cell equals table

357
00:20:15,550 --> 00:20:16,320
view.

358
00:20:16,380 --> 00:20:20,170
Dequeue reusable cell with identifier.

359
00:20:20,260 --> 00:20:24,250
We have not created this identifier yet so we're gonna assume its name.

360
00:20:24,250 --> 00:20:28,100
We're going to call this cat a category cell.

361
00:20:28,600 --> 00:20:29,500
OK.

362
00:20:29,500 --> 00:20:34,570
And we're going to cast it as a category cell.

363
00:20:34,570 --> 00:20:41,360
So what we're doing is we're grabbing we're grabbing the table view that is working with this with this

364
00:20:41,380 --> 00:20:44,400
delegate and we're calling dequeue reusable cell.

365
00:20:44,400 --> 00:20:49,670
And this is the function you call to get a reusable cell did you know on a table view on us.

366
00:20:49,840 --> 00:20:53,700
OK in a similar with Android slathers one two three four items visible.

367
00:20:53,740 --> 00:20:55,130
Did you know that.

368
00:20:55,210 --> 00:21:00,010
Let's see if you had 100 items they would not be under here hidden there would only be probably five

369
00:21:00,010 --> 00:21:01,420
or six cells altogether.

370
00:21:01,450 --> 00:21:05,500
And what happens is it takes the one off the bottom that's no longer on the screen and puts it back

371
00:21:05,500 --> 00:21:09,850
on the top so it grabs the item still in memory so it doesn't have to recreate it and slow down your

372
00:21:09,850 --> 00:21:10,740
app and it just.

373
00:21:10,750 --> 00:21:12,950
Hey I got a new I got your old cell for you.

374
00:21:13,090 --> 00:21:15,020
What data should we put in it to update it.

375
00:21:15,130 --> 00:21:16,240
That's all.

376
00:21:16,360 --> 00:21:16,880
What.

377
00:21:16,930 --> 00:21:17,260
Yeah.

378
00:21:17,290 --> 00:21:20,980
It just grabs an original cell you've already used and you update it with new data.

379
00:21:20,980 --> 00:21:22,120
That's how it works.

380
00:21:22,120 --> 00:21:25,210
So what we're doing here is we're grabbing a reusable cell.

381
00:21:25,610 --> 00:21:25,900
OK.

382
00:21:25,900 --> 00:21:30,060
Called category cell which we have not set yet and easy.

383
00:21:30,070 --> 00:21:35,490
Now all we have to do is grab the category for this row and then put it in the update View's function.

384
00:21:35,500 --> 00:21:38,490
So you say let a category.

385
00:21:38,860 --> 00:21:44,240
How do you think we can grab the appropriate category or what I want you to do OK on your own pozières

386
00:21:44,290 --> 00:21:49,420
video that I want you to figure out how to grab the proper category for the proper row and store it

387
00:21:49,420 --> 00:21:50,060
in this variable

388
00:21:57,530 --> 00:21:59,440
did you do it.

389
00:21:59,670 --> 00:22:03,430
I know some of you did and I know some of you didn't because that's how it always works.

390
00:22:03,960 --> 00:22:05,840
But for those you did congratulations.

391
00:22:05,850 --> 00:22:09,310
You know if you figured it out if you didn't that's OK because we're in India right now.

392
00:22:09,370 --> 00:22:11,090
So let category.

393
00:22:11,170 --> 00:22:12,950
Equals OK.

394
00:22:12,990 --> 00:22:13,860
You ready.

395
00:22:13,890 --> 00:22:17,710
We're going to see data service that instance.

396
00:22:17,800 --> 00:22:19,290
Get categories.

397
00:22:19,290 --> 00:22:21,350
How do we get the right category at the right row.

398
00:22:21,360 --> 00:22:22,360
What do we do.

399
00:22:22,740 --> 00:22:28,900
Well we just grab the item from the array index path row.

400
00:22:29,420 --> 00:22:30,150
OK.

401
00:22:30,630 --> 00:22:32,360
Does this look really funky to you.

402
00:22:32,450 --> 00:22:32,700
OK.

403
00:22:32,700 --> 00:22:33,750
You're like what's going on Mark.

404
00:22:33,780 --> 00:22:35,130
This is Grady's index.

405
00:22:35,280 --> 00:22:39,150
When you're teaching a raise you never taught as to put square brackets after parentheses that doesn't

406
00:22:39,150 --> 00:22:39,900
make any sense to me.

407
00:22:39,900 --> 00:22:43,140
Well it's because we're returning an array from a function.

408
00:22:43,140 --> 00:22:45,080
So this would be the equivalent of doing this.

409
00:22:45,120 --> 00:22:52,630
I could have said let the categories equal data service from instance Dockett category.

410
00:22:52,630 --> 00:22:58,270
So it's stores like you know the the array inside of a category here are the categories array.

411
00:22:58,410 --> 00:23:05,220
And then what I could have done was I could have just you know I could have set categories like so.

412
00:23:05,380 --> 00:23:06,000
OK.

413
00:23:06,100 --> 00:23:11,040
All that certain look familiar to me now because that's an array and you're grabbing an index out of

414
00:23:11,040 --> 00:23:11,880
that array.

415
00:23:12,330 --> 00:23:16,730
But I do that when we can do it so much more quickly with one line of code.

416
00:23:17,100 --> 00:23:22,140
So grabbing the categories and there were grabbing the specific item out of that category.

417
00:23:22,590 --> 00:23:23,320
Easy peasy.

418
00:23:23,490 --> 00:23:24,040
OK.

419
00:23:24,330 --> 00:23:27,500
And if it's not easy Don't worry it just takes lots of practice.

420
00:23:27,570 --> 00:23:28,380
OK.

421
00:23:28,950 --> 00:23:30,710
You'll get this down over and over again.

422
00:23:30,900 --> 00:23:34,110
Code repetition code every day study every day.

423
00:23:34,110 --> 00:23:39,820
Let's go ahead and update the cell now so cell that update views and it's looking for category.

424
00:23:39,840 --> 00:23:42,440
So we passed in the category that we just grabbed.

425
00:23:42,930 --> 00:23:43,720
OK.

426
00:23:44,280 --> 00:23:46,240
And that's looking really good as well too.

427
00:23:46,260 --> 00:23:50,880
Now a lot of developers are really tempted to do some nasty code that goes something like this instead

428
00:23:50,880 --> 00:23:53,850
of just updating views and letting the view manage itself.

429
00:23:53,850 --> 00:23:55,400
They like to do things like this sort of like that.

430
00:23:55,410 --> 00:24:01,900
Like the say cell dot image the dot image equals you know category dot image name.

431
00:24:01,950 --> 00:24:06,770
So the same thing we did in our view but they like to do it here from the tail view and that's bad practice.

432
00:24:06,780 --> 00:24:08,920
You always want your views to be self-contained.

433
00:24:08,960 --> 00:24:10,230
You should manage themselves.

434
00:24:10,230 --> 00:24:14,970
The controller should say what's going on the screen at different times but every view that you have

435
00:24:15,000 --> 00:24:16,030
should manage itself.

436
00:24:16,050 --> 00:24:21,000
If it's of any consequence or significance which a table you sell is so don't ever do this don't ever

437
00:24:21,000 --> 00:24:25,620
manipulate your table use cells from within your table view self index path.

438
00:24:25,630 --> 00:24:30,680
It's nasty and it's something I teach and if you learned it you didn't learn it from me.

439
00:24:30,690 --> 00:24:32,970
So do it this way it's much better.

440
00:24:32,970 --> 00:24:38,150
All right and so what we're going to do next is return that cell because the function table you self

441
00:24:38,160 --> 00:24:38,980
wrote and expand.

442
00:24:39,020 --> 00:24:41,540
It wants us to return a cell.

443
00:24:41,560 --> 00:24:50,150
Else let's just return an empty one return category cell like an empty cell like so OCHA.

444
00:24:50,570 --> 00:24:53,980
Are you with me so far breaking really good progress here.

445
00:24:54,020 --> 00:24:57,480
We've got our our delegate function implemented.

446
00:24:58,040 --> 00:25:01,190
Self-fertile index path and number of rows in S..

447
00:25:01,190 --> 00:25:05,880
One other thing we need to do is set the data source and delegate of the table view.

448
00:25:05,900 --> 00:25:15,950
So we're going to say you did load categories table data source equals self category table delegate

449
00:25:16,440 --> 00:25:21,360
equal self-dual we're saying is hey the data sources this class this category is VC view controller

450
00:25:21,380 --> 00:25:25,430
self and we're all saying hey the data source is also this Self.

451
00:25:25,470 --> 00:25:31,790
OK if I took these off we would get an error here because it's like what's going on.

452
00:25:31,790 --> 00:25:35,000
I don't this doesn't make any sense to me where you're setting these delegates.

453
00:25:35,030 --> 00:25:39,310
You cannot assign value of categories to type your data source because it doesn't exist.

454
00:25:39,410 --> 00:25:41,800
But once you implement the protocols.

455
00:25:42,060 --> 00:25:47,810
OK those properties do exist and you're setting the class you said in into class on them.

456
00:25:47,810 --> 00:25:52,690
So OK this class itself categories we see this view controller.

457
00:25:52,850 --> 00:25:54,380
So that's looking good.

458
00:25:54,380 --> 00:25:56,510
We need to do a little more clean up here in our story board.

459
00:25:56,540 --> 00:26:01,280
We've used this category cell identifier for the reusable cell but we actually haven't given it a name

460
00:26:02,010 --> 00:26:03,520
an identifier in our storyboard.

461
00:26:03,530 --> 00:26:05,280
So let's go back to the main storyboard.

462
00:26:05,600 --> 00:26:06,290
OK.

463
00:26:06,680 --> 00:26:13,600
Click your cell category cell and open up the right hand side here and we're going to go to the attributes

464
00:26:13,610 --> 00:26:15,830
inspector and see this reuse identifier.

465
00:26:15,830 --> 00:26:22,130
This is where we're going to type in the we go.

466
00:26:22,140 --> 00:26:26,700
We're going to type in the category self that's the name of the identifier that we wrote in the code

467
00:26:26,700 --> 00:26:28,630
and it has to be the same in a lot of developers.

468
00:26:28,640 --> 00:26:33,840
Forget this they forget this spot right here and they bang their heads.

469
00:26:33,870 --> 00:26:34,880
You have to do this.

470
00:26:34,890 --> 00:26:37,900
You don't put the identifier it doesn't know how to reuse the cell.

471
00:26:37,950 --> 00:26:38,460
OK.

472
00:26:38,700 --> 00:26:41,150
Rookie mistake Hogan.

473
00:26:41,740 --> 00:26:43,950
Let's run it and see if it works within a lot of talking.

474
00:26:43,950 --> 00:26:45,990
We haven't actually read it and see if it works.

475
00:26:54,440 --> 00:26:54,840
OK.

476
00:26:55,010 --> 00:27:01,150
So looks like we have an air did not work Boehme category table that data source equals self.

477
00:27:01,400 --> 00:27:02,790
And it says it's Neal.

478
00:27:02,840 --> 00:27:10,460
This would indicate to me that somehow we lost our category table connection in Interface Builder which

479
00:27:10,460 --> 00:27:14,580
seems strange to me because we said it Melissas double check anyway.

480
00:27:14,720 --> 00:27:18,880
I also noticed an internal air Kirt editing functionality maybe limited.

481
00:27:18,950 --> 00:27:22,250
This is currently a beta software and so it could have bugs as well too.

482
00:27:22,400 --> 00:27:23,570
But this shouldn't be a big deal.

483
00:27:23,810 --> 00:27:25,190
Let's look at our table view.

484
00:27:25,560 --> 00:27:30,060
OK it looks like our connection was lost which it is.

485
00:27:30,080 --> 00:27:31,150
Let's reset here.

486
00:27:31,220 --> 00:27:32,720
Category table the table.

487
00:27:32,720 --> 00:27:34,890
You get on.

488
00:27:34,890 --> 00:27:38,050
Glad you saw that it's a good way to know when something's wrong.

489
00:27:38,090 --> 00:27:39,920
Mark how did you know that it wasn't there.

490
00:27:40,010 --> 00:27:43,560
It was said it was nyl it said the table view that delegate was nil.

491
00:27:43,650 --> 00:27:49,240
Don't think it could be is it wasn't it.

492
00:27:49,250 --> 00:27:51,230
It wasn't in memory wasn't even created yet.

493
00:27:51,340 --> 00:27:53,940
OK so it's not working clearly.

494
00:27:53,960 --> 00:27:58,680
So we've got no sales here showing on the screen and it's just blank.

495
00:27:59,210 --> 00:28:00,880
So we should fix that.

496
00:28:00,890 --> 00:28:07,380
Let's go back to our code word induced and debugging.

497
00:28:07,920 --> 00:28:13,060
Close this right hand side here yes.

498
00:28:13,080 --> 00:28:20,490
Another rookie mistake which US long term developers still make is we didn't set the outlets on the

499
00:28:20,790 --> 00:28:29,400
table of you so it was going to in-store board and it's click to sell here or we did and it deleted

500
00:28:29,400 --> 00:28:30,270
those as well too.

501
00:28:30,300 --> 00:28:32,270
Which is also a possibility.

502
00:28:32,310 --> 00:28:37,780
So category so right click it you know our views aren't even available here.

503
00:28:37,830 --> 00:28:39,760
I think our tax code hosed them.

504
00:28:39,770 --> 00:28:42,390
So let's go back over here and look at that.

505
00:28:42,390 --> 00:28:44,110
We lost our class as well too.

506
00:28:44,250 --> 00:28:47,020
So I clicked the identity inspector here.

507
00:28:47,220 --> 00:28:47,630
OK.

508
00:28:47,640 --> 00:28:53,100
And I'm just resetting the category so somewhere in here X code chopped up our stuff.

509
00:28:53,110 --> 00:28:55,080
So that's why it's not working.

510
00:28:55,120 --> 00:29:01,380
All right now if I right click category sell you'll see the category image and the category title.

511
00:29:01,380 --> 00:29:02,300
Perfect.

512
00:29:02,460 --> 00:29:06,110
OK this is good too you're seeing debugging real time problems that are happening.

513
00:29:06,180 --> 00:29:06,930
Mark why.

514
00:29:07,050 --> 00:29:07,800
Why is this blank.

515
00:29:07,800 --> 00:29:12,630
Well I'm thinking in my head the only reason why I can be blank is if the views are one is the data

516
00:29:12,630 --> 00:29:15,070
is not there but the data is there we've written that code.

517
00:29:15,090 --> 00:29:17,170
Or if the views aren't connected which they weren't.

518
00:29:17,250 --> 00:29:19,020
So there was one or two possibilities.

519
00:29:19,100 --> 00:29:20,220
So let's run it again and see

520
00:29:27,700 --> 00:29:29,120
and there we go.

521
00:29:29,230 --> 00:29:30,870
It's not perfect but you know what is cool.

522
00:29:30,880 --> 00:29:36,130
You can actually scroll a couple problems I see here is these are supposed to have a little bit of spacing.

523
00:29:36,340 --> 00:29:38,450
So let's fix that and let's get rid of this ugly scroll.

524
00:29:38,560 --> 00:29:40,810
I always hate the scroll things on the sides and the bottom.

525
00:29:40,810 --> 00:29:42,350
So let's fix those as well too.

526
00:29:42,640 --> 00:29:45,370
So how would we fix this how would we create spaces between cells.

527
00:29:45,370 --> 00:29:46,550
Well you really can't.

528
00:29:46,580 --> 00:29:50,210
You can't create a spacer between cells.

529
00:29:50,240 --> 00:29:55,140
What you do is you simulate that space using other means and methods that you already know how to do.

530
00:29:55,150 --> 00:29:59,950
So what I think we're going to do is just add a little more padding causes left inside a little more

531
00:29:59,950 --> 00:30:02,010
padding on this image itself here.

532
00:30:02,020 --> 00:30:11,140
So in this category image what we can do is just bring a little in from the bottom here and the top

533
00:30:11,140 --> 00:30:11,610
probably.

534
00:30:11,620 --> 00:30:13,600
So let's look at our measurements here.

535
00:30:13,600 --> 00:30:16,570
So we've got this bottom space and top space.

536
00:30:16,570 --> 00:30:22,140
You know what I think I want to do is delete these in the top space and we'll reset them.

537
00:30:22,150 --> 00:30:23,170
This is faster that way.

538
00:30:23,170 --> 00:30:30,610
So click the pen menu and what I'm going to do is I'm going to say three from the top and three from

539
00:30:30,610 --> 00:30:31,690
the bottom.

540
00:30:31,750 --> 00:30:32,190
OK.

541
00:30:32,410 --> 00:30:35,200
So three from the top three from the bottom.

542
00:30:35,200 --> 00:30:36,610
Bring it up a little bit there.

543
00:30:37,030 --> 00:30:38,380
Let's run it again and see how it looks.

544
00:30:38,380 --> 00:30:42,870
I didn't put more than three because if you put top on the bottom three would add up to six and would

545
00:30:42,880 --> 00:30:47,690
give it more spacing so I'm just trying it out with three to see how it looks good.

546
00:30:47,710 --> 00:30:50,900
It has these ugly lines in between which I definitely don't want.

547
00:30:50,960 --> 00:30:53,330
So let's go and get rid of those and that's really easy.

548
00:30:53,350 --> 00:30:56,470
All you have to do to get rid of those lines is click your table view itself.

549
00:30:56,470 --> 00:30:57,540
Category table.

550
00:30:57,790 --> 00:30:58,160
OK.

551
00:30:58,190 --> 00:31:02,370
Click the attributes inspector and see the step the separator how it says default.

552
00:31:02,590 --> 00:31:04,160
Change it to none.

553
00:31:04,210 --> 00:31:06,370
And then let's run it again and see how it looks

554
00:31:12,440 --> 00:31:13,010
wonderful.

555
00:31:13,080 --> 00:31:19,100
OK this is kind of looking like the image here but not very much code I think art text is like black

556
00:31:19,100 --> 00:31:23,080
and should be dark gray but I don't care I'm not going to tell the designer if you don't care.

557
00:31:23,390 --> 00:31:24,320
This is looking good though.

558
00:31:24,380 --> 00:31:27,500
So what we've done here is we've set images dynamically as if we got them from a server.

559
00:31:27,500 --> 00:31:32,570
We also set the titles of those cells that are dynamically as if we got them from a server somewhere

560
00:31:32,600 --> 00:31:33,790
and we're repopulating data.

561
00:31:33,800 --> 00:31:37,910
And then when you know hypothetically when shirts and clothes and things products would change on line

562
00:31:37,910 --> 00:31:40,870
they would change your automatically which is really cool.

563
00:31:40,880 --> 00:31:42,350
So this is looking good.

564
00:31:42,350 --> 00:31:46,410
One more thing let's get rid of those ugly scrolling things.

565
00:31:46,730 --> 00:31:52,850
So it's click your table view here and let's go to our scrolling.

566
00:31:53,070 --> 00:31:55,550
Let's take up the scroll indicator called scroll indicators.

567
00:31:55,580 --> 00:31:58,940
I don't you know I don't remember the name because I just want to think about it.

568
00:31:59,190 --> 00:32:00,540
OK I took both of those off.

569
00:32:00,590 --> 00:32:02,700
And this is good.

570
00:32:03,260 --> 00:32:06,330
We're good here so I won't call this video done we've done a lot.

571
00:32:06,400 --> 00:32:07,540
OK we've done a lot.

572
00:32:07,550 --> 00:32:09,650
We've created a custom table view cell.

573
00:32:09,650 --> 00:32:10,910
We pass data into it.

574
00:32:10,910 --> 00:32:12,770
We implemented delegate functions.

575
00:32:12,870 --> 00:32:14,520
Ok this is great here.

576
00:32:14,570 --> 00:32:17,390
We've implemented delegate functions.

577
00:32:17,570 --> 00:32:22,370
So remember you implement a protocol and then it calls delegate functions or a protocol has a delegate

578
00:32:22,400 --> 00:32:24,020
or something that represents the protocol.

579
00:32:24,020 --> 00:32:27,140
You'll learn more about this and then delegate X on its behalf.

580
00:32:27,140 --> 00:32:32,810
In our case the delegate was the category ABC and so we implemented self-carriage the index path which

581
00:32:32,810 --> 00:32:34,520
basically dequeue is a cell.

582
00:32:34,660 --> 00:32:34,990
Okay.

583
00:32:35,000 --> 00:32:37,990
And then it makes it reusable and then you update the data in it.

584
00:32:38,000 --> 00:32:43,040
OK we said an identifier on it here and in the board and we said how many rows we want to show all together.

585
00:32:43,160 --> 00:32:43,610
OK.

586
00:32:43,640 --> 00:32:47,750
So the delegate and the data source here of the table and we connected that outlets and we did some

587
00:32:47,750 --> 00:32:51,510
debugging to X code just hosed all of our wonderful work.

588
00:32:51,530 --> 00:32:53,060
We knew exactly how to fix it.

589
00:32:53,060 --> 00:32:57,740
So a lot of good stuff here you may have to watch us over and over again but when I'm programming it

590
00:32:57,740 --> 00:32:59,840
I was to build it professionally and on the slopes.

591
00:33:00,020 --> 00:33:04,270
There's not a day that goes by where someone on our team is not working with table views and doing this

592
00:33:04,310 --> 00:33:05,200
exact type of code.

593
00:33:05,200 --> 00:33:06,770
So that's it for now.

594
00:33:06,780 --> 00:33:08,150
Mark Price a slopestyle.

595
00:33:08,200 --> 00:33:09,200
Let's move on on board.
