1
00:00:05,510 --> 00:00:06,920
Yo what's up everyone.

2
00:00:06,930 --> 00:00:09,440
Mark Price does slopes dotcom.

3
00:00:09,570 --> 00:00:11,550
And let's continue building our app here.

4
00:00:11,550 --> 00:00:12,840
We're making great progress.

5
00:00:12,840 --> 00:00:19,350
We want to do next is actually have this product screen show and we want to get our collection view

6
00:00:19,350 --> 00:00:21,650
all configured etc. etc..

7
00:00:21,660 --> 00:00:29,010
So first things is we need to make sure we have an identifier on our Segway So click your Segway and

8
00:00:29,130 --> 00:00:30,970
then add the attributes inspector over here.

9
00:00:31,110 --> 00:00:31,910
Set an identifier.

10
00:00:31,920 --> 00:00:39,230
I like to just set this to The View Controller that we are going to which I believe is the product B

11
00:00:39,240 --> 00:00:44,420
C category as we said we haven't created it yet.

12
00:00:44,420 --> 00:00:46,940
Well we should do that and then we'll set the identifier.

13
00:00:46,940 --> 00:00:54,190
So in your controller folder Let's go to a new file cocoa touch class and instead of you a collection

14
00:00:54,210 --> 00:01:06,520
B-cell we will say you view controller and we will call this products beseem press Enter create.

15
00:01:06,790 --> 00:01:07,150
OK.

16
00:01:07,170 --> 00:01:09,300
Now go back to the main storyboard here.

17
00:01:09,300 --> 00:01:15,810
We'll select our view controller will change its class to the products ABC wonderful.

18
00:01:15,900 --> 00:01:23,910
And then on the segue here now we can set the identifier to products and we see it there.

19
00:01:24,120 --> 00:01:24,380
OK.

20
00:01:24,390 --> 00:01:26,790
So the Segway identifiers in there.

21
00:01:26,790 --> 00:01:33,630
Let's go back to our categories Visi and what we want to do is when a category is selected like tapped

22
00:01:33,720 --> 00:01:39,270
we want to show another view controller so really all we're doing here is presenting a Segway and then

23
00:01:39,510 --> 00:01:44,070
passing the appropriate data into the other view controller that we're going to be going to how do we

24
00:01:44,070 --> 00:01:44,460
do that.

25
00:01:44,460 --> 00:01:53,040
Well the Table View delegate has a really cool function called did select row index path.

26
00:01:53,040 --> 00:01:58,960
One thing that's really important is that you don't accidentally click did de-select so did de-select.

27
00:01:59,050 --> 00:02:03,720
Ok that's when they've selected and taken their finger off a lot of new developers actually entered

28
00:02:03,720 --> 00:02:06,970
this in and then the table view is not working correctly when you're tapping it.

29
00:02:06,970 --> 00:02:11,250
So we want did select row index path.

30
00:02:11,470 --> 00:02:12,200
OK.

31
00:02:12,540 --> 00:02:14,900
So we're going to have roads going to tell us which row is tapped.

32
00:02:14,910 --> 00:02:17,520
And then we can build out some logic here.

33
00:02:17,550 --> 00:02:18,630
No big deal.

34
00:02:18,630 --> 00:02:22,300
So first things first is let's grab the appropriate category that was tapped.

35
00:02:22,410 --> 00:02:24,060
So let category.

36
00:02:24,110 --> 00:02:28,540
Category equals data service.

37
00:02:28,560 --> 00:02:41,130
Get categories and data centers get categories and we're going to say Index path dot row.

38
00:02:41,670 --> 00:02:42,060
OK.

39
00:02:42,160 --> 00:02:45,620
So we're just grabbing the category.

40
00:02:45,840 --> 00:02:50,380
You know I think it's good category.

41
00:02:50,710 --> 00:02:57,630
Now that's correct datasource get category it's trippin out it's just trippin out here.

42
00:02:57,630 --> 00:03:04,800
I'm just going to copy what we have up here because this one has been out X code and it's trippin.

43
00:03:05,390 --> 00:03:06,670
So there's our category.

44
00:03:06,860 --> 00:03:07,700
Wonderful.

45
00:03:07,760 --> 00:03:14,030
And then what we want to do is say perform a segue like so with identifier where we know it's the products

46
00:03:14,060 --> 00:03:18,110
Visi Segway and the sender basically will object.

47
00:03:18,110 --> 00:03:19,230
We want to pass in this.

48
00:03:19,250 --> 00:03:23,300
So when I prepare for SEGUI is called We have data available to us and this is where we pass in the

49
00:03:23,300 --> 00:03:28,120
category so we're passing in data here into our perform Segway.

50
00:03:28,310 --> 00:03:35,750
So then when prepare for Segway called we can then pass that over into our products and then sell it

51
00:03:35,750 --> 00:03:38,870
to the prepare for Segway function like so.

52
00:03:38,900 --> 00:03:50,170
And you've done this before if let products be C equals Segway destination as products.

53
00:03:50,390 --> 00:03:55,510
So we're describing the destination View Controller and we're casting it into the appropriate view controller.

54
00:03:55,670 --> 00:03:56,210
Okay.

55
00:03:56,510 --> 00:04:02,690
And then what we'll do is we will set the category on that view controller but we don't have any variables

56
00:04:02,690 --> 00:04:03,470
or anything for that yet.

57
00:04:03,470 --> 00:04:09,250
So what I want to do is go to my products Visi get rid of this comment here.

58
00:04:09,320 --> 00:04:16,250
And what I want to do is see what it did receive memory warning is its great function here called initialized

59
00:04:16,250 --> 00:04:17,110
products.

60
00:04:17,410 --> 00:04:18,170
Okay.

61
00:04:18,620 --> 00:04:22,910
And then what we'll do is we'll pass in.

62
00:04:23,200 --> 00:04:28,310
Well what do we want to call this exactly initialized products for like a category title like will pass

63
00:04:28,310 --> 00:04:32,060
in a title or just pass and the whole category.

64
00:04:32,060 --> 00:04:33,370
Just thinking aloud here.

65
00:04:33,650 --> 00:04:36,390
Okay initialized products category.

66
00:04:36,920 --> 00:04:37,770
Wonderful.

67
00:04:38,000 --> 00:04:43,450
And then what we'll do here is we'll actually store a list of products so same as we've done before

68
00:04:43,460 --> 00:04:44,970
private set.

69
00:04:45,350 --> 00:04:54,190
And then it's if I can type public var and this one is going to be called products.

70
00:04:54,200 --> 00:04:54,720
All right.

71
00:04:54,920 --> 00:05:05,690
And it's going to be an empty array type product like so if you're wondering why we're making this an

72
00:05:05,690 --> 00:05:06,470
empty array.

73
00:05:06,550 --> 00:05:14,300
And the reason is let's say that we the data hasn't loaded yet you're getting it from the internet somewhere.

74
00:05:14,480 --> 00:05:19,460
Well you want an empty array to base your collection view off of Otherwise it was just nail your collection

75
00:05:19,460 --> 00:05:21,830
if you would look for an item and it in your whole app would crash.

76
00:05:21,820 --> 00:05:24,700
So that's why we're creating an empty array here.

77
00:05:25,030 --> 00:05:25,720
OK.

78
00:05:25,820 --> 00:05:30,830
And what we're going to do here is simply use the function that we already built in our data service

79
00:05:30,830 --> 00:05:34,410
to get the appropriate product for this category that we are passing in.

80
00:05:34,680 --> 00:05:38,510
OK so what we're going to do is we're going to say self-direct.

81
00:05:38,690 --> 00:05:47,480
So don't you say self-heating to say products equals data service and since dogs get products for category

82
00:05:47,480 --> 00:05:51,400
title we're going to say category title.

83
00:05:51,530 --> 00:05:56,210
So it's going to happen is our products are going to be populated with products and we're just passing

84
00:05:56,210 --> 00:06:01,540
in the title that was passed in the categories we see here to the products see.

85
00:06:01,570 --> 00:06:08,730
And so now this initialized products function we can actually call from right here so we can say products

86
00:06:08,730 --> 00:06:19,900
AVC dot initialized products and we can pass in the sender as a product or category.

87
00:06:20,060 --> 00:06:20,850
There we go like so

88
00:06:24,760 --> 00:06:25,300
OK.

89
00:06:25,340 --> 00:06:29,690
So what we're doing here is we're grabbing the products Visi and we're just calling that initialized

90
00:06:29,690 --> 00:06:31,580
products function that we just created.

91
00:06:31,580 --> 00:06:37,180
Sender you're like what descender center is just the category that we passed in so remember up here

92
00:06:37,210 --> 00:06:41,540
Pyrenean ended select ROA index path we passed in the category to the sender.

93
00:06:41,540 --> 00:06:46,460
All we're doing here is grabbing the sender because when you pass it in the parameter type is any like

94
00:06:46,490 --> 00:06:47,590
any object.

95
00:06:47,630 --> 00:06:52,890
And so we have to specify that this is a category so sender as category and why am I force in wrapping

96
00:06:52,880 --> 00:06:53,030
it.

97
00:06:53,090 --> 00:06:58,930
Because I know for a fact that it is a category because I just said it right there.

98
00:06:58,990 --> 00:06:59,190
OK.

99
00:06:59,210 --> 00:07:01,850
So you can be sure that this is going to cast correctly.

100
00:07:01,850 --> 00:07:06,690
So products these initialized products sender as category.

101
00:07:06,700 --> 00:07:07,190
Okay.

102
00:07:07,190 --> 00:07:13,250
And one thing that we probably want to do here is create an assertion so at build time we know that

103
00:07:13,250 --> 00:07:14,620
this is working correctly.

104
00:07:14,660 --> 00:07:17,060
And then I'll feel more comfortable using that force unwrap.

105
00:07:17,090 --> 00:07:18,260
So let's do that now.

106
00:07:19,730 --> 00:07:30,540
We're going to say assert that sender as with a question mark category is not equal to nil.

107
00:07:30,850 --> 00:07:31,620
Okay.

108
00:07:31,640 --> 00:07:37,660
And this assertion is good because what it's going to do is at build time this is only for build time

109
00:07:37,870 --> 00:07:40,220
in developed motets not for production.

110
00:07:40,220 --> 00:07:44,870
What's going to happen is this assertion is going to be called and it's going to say it absolutely must

111
00:07:44,870 --> 00:07:48,590
be of type category when we cast it and if it's not it's going to crash your app at build time.

112
00:07:48,620 --> 00:07:52,490
As a developer so as a developer you're going through you're building your project and then you go in

113
00:07:52,490 --> 00:07:56,570
here and then your app crashes you know that you need to fix it we're forcing a crash here if it's not

114
00:07:56,570 --> 00:07:56,930
working.

115
00:07:56,930 --> 00:07:59,390
So at runtime it will definitely work.

116
00:07:59,490 --> 00:08:02,930
OK this is just a layer of protection in your development that will help you out.

117
00:08:02,930 --> 00:08:07,520
Now you maybe you think it will mark why didn't you do a guard statement in the casting OK or why didn't

118
00:08:07,520 --> 00:08:10,680
you do an if let if let sender as category.

119
00:08:10,700 --> 00:08:16,630
Well the reason I didn't do an if LET or guard is because my application requires this to be a category.

120
00:08:16,670 --> 00:08:22,090
It's not chance ok it's not user base where it might be a category it might be something else.

121
00:08:22,100 --> 00:08:25,300
Ok if that was the case we would use the guard or an inlet.

122
00:08:25,460 --> 00:08:30,570
But since my app requires that this is a category when we cast it it makes more sense to use an assertion.

123
00:08:30,680 --> 00:08:31,940
So build time.

124
00:08:31,940 --> 00:08:34,960
If it's not working it crashes our app which is what we want.

125
00:08:35,080 --> 00:08:36,020
OK we can guarantee it.

126
00:08:36,020 --> 00:08:36,290
No.

127
00:08:36,320 --> 00:08:44,070
So I feel a lot better about force unwrapping the this or forecasting this here so we're initialising

128
00:08:44,090 --> 00:08:46,250
the products center as category.

129
00:08:46,250 --> 00:08:46,850
This is great.

130
00:08:46,850 --> 00:08:53,570
And then in the products you see it's going to go ahead and set the products to the products that we

131
00:08:54,020 --> 00:08:55,860
have here in our data service.

132
00:08:55,880 --> 00:09:01,010
So the next thing we need to do is get our collection of view actually working so let's implement a

133
00:09:01,010 --> 00:09:06,320
couple of protocols put a comma after you have your controller and we're going to use a collection of

134
00:09:06,320 --> 00:09:09,860
view delegate and UI collection.

135
00:09:09,930 --> 00:09:14,030
The new data source like we've done before.

136
00:09:14,150 --> 00:09:19,700
And of course we need the outlet for our collection of use at Iby outlet weak var and we're going to

137
00:09:19,700 --> 00:09:25,360
say products collection of type you collection view.

138
00:09:26,010 --> 00:09:26,630
OK.

139
00:09:26,990 --> 00:09:28,480
And we're putting the exclamation there at the end.

140
00:09:28,490 --> 00:09:31,140
Meaning it's an implicitly unwrapped optional.

141
00:09:31,160 --> 00:09:34,660
And it's saying hey you haven't implemented the function so click the red button up here.

142
00:09:34,670 --> 00:09:35,880
Do you want to add protocol stubs.

143
00:09:35,900 --> 00:09:37,030
Absolutely.

144
00:09:37,310 --> 00:09:44,730
So command X protocol stubs will put them where they actually belong down here I get to get rid of the

145
00:09:44,730 --> 00:09:46,870
available nonsense.

146
00:09:47,070 --> 00:09:49,740
And this year the code and get rid of that there.

147
00:09:49,880 --> 00:09:50,680
OK.

148
00:09:51,240 --> 00:09:58,710
And what we do here and feuded load is we will say products collection that datasource equals self and

149
00:09:58,800 --> 00:10:00,220
products collection.

150
00:10:00,240 --> 00:10:02,190
Delegate equals self.

151
00:10:02,190 --> 00:10:09,900
OK we are saying that hey this collection of view is going to be the delegate and implement the protocols

152
00:10:10,020 --> 00:10:14,340
the appropriate protocols to get this working OK.

153
00:10:14,510 --> 00:10:16,750
And so a number of items in section.

154
00:10:16,770 --> 00:10:18,090
Now there are multiple.

155
00:10:18,150 --> 00:10:21,410
You could have an app with multiple sections a collection view or table view.

156
00:10:21,420 --> 00:10:22,880
In our case we only have one.

157
00:10:22,890 --> 00:10:27,160
So what I'm going to do is just simply return products that count.

158
00:10:27,390 --> 00:10:34,800
Otherwise what you might have done is you might have said if Section equals 1 then you return three

159
00:10:34,970 --> 00:10:35,600
you know.

160
00:10:35,640 --> 00:10:36,420
Or.

161
00:10:36,550 --> 00:10:39,500
Well you know whatever number it is or some other collection.

162
00:10:39,630 --> 00:10:41,640
Else if Section equals to return this many.

163
00:10:41,640 --> 00:10:48,000
But in our case again we only have one section so we're going to return products don't count and then

164
00:10:48,000 --> 00:10:49,470
sell for item index path.

165
00:10:49,470 --> 00:10:52,470
This is very similar to what we've done with the table view.

166
00:10:52,920 --> 00:10:56,080
OK we're simply going to say if let.

167
00:10:56,080 --> 00:10:59,280
Sell equals collection view.

168
00:10:59,400 --> 00:11:01,400
Dick Hugh reusable sell.

169
00:11:01,590 --> 00:11:05,610
And this one's going to be the product sell.

170
00:11:05,610 --> 00:11:09,740
I think that's what we called it or what we will call it if we haven't done it yet for index path.

171
00:11:09,750 --> 00:11:14,730
And in this case it's looking for the index path that's being passed in right here from the function.

172
00:11:14,730 --> 00:11:16,580
So there's our cell if let's sell.

173
00:11:17,100 --> 00:11:21,960
And then what we want to do in the cell is just passing the data that we're going to need.

174
00:11:22,020 --> 00:11:27,540
And so let's look at our cell product sell and we don't have a way to update the data here so let's

175
00:11:27,540 --> 00:11:29,190
create our function to do that.

176
00:11:29,220 --> 00:11:35,160
So function update views and we're going to pass in a product.

177
00:11:35,550 --> 00:11:38,310
We've done this before with the table view very similar.

178
00:11:38,700 --> 00:11:46,320
And what we'll say is we will say product image image equals image named.

179
00:11:46,740 --> 00:11:57,000
And this is going to be product image name and then product title text equals product that title and

180
00:11:57,000 --> 00:12:01,880
product price text equals product price.

181
00:12:01,890 --> 00:12:07,710
So all we're doing here is every time a collection of cell is created or Decoud we're going to pass

182
00:12:07,710 --> 00:12:10,020
in the appropriate product and update the view.

183
00:12:10,020 --> 00:12:11,070
So it's showing the correct data.

184
00:12:11,070 --> 00:12:16,390
And this is important because of views on a collection of cell and collection of you and a table of

185
00:12:16,410 --> 00:12:17,490
you are recycled.

186
00:12:17,490 --> 00:12:19,580
So we have to continually update the views.

187
00:12:19,780 --> 00:12:20,800
OK.

188
00:12:20,850 --> 00:12:22,140
So that looks good there.

189
00:12:22,140 --> 00:12:27,840
So back in our products we see what we can do now is we can grab the appropriate product and then pass

190
00:12:27,840 --> 00:12:35,020
it into the cell so we can say let product equals products index path dot Roe.

191
00:12:35,130 --> 00:12:40,110
Okay we're grabbing the appropriate Roe for the products and we're storing for the product and we're

192
00:12:40,110 --> 00:12:46,340
storing it here in this product constant and then sell that update views.

193
00:12:46,920 --> 00:12:48,440
We forgot to cast it.

194
00:12:48,510 --> 00:12:53,950
So let's cast it now so as it were and say product sale.

195
00:12:54,290 --> 00:12:56,730
There we go now it knows it's a product sell.

196
00:12:56,860 --> 00:13:03,930
Once I sell that update views and we'll pass in the product and then we will return the cell as the

197
00:13:03,930 --> 00:13:05,580
function requires.

198
00:13:05,580 --> 00:13:10,470
Otherwise if this didn't cast appropriately like when we converted the cell it didn't it wasn't a product

199
00:13:10,470 --> 00:13:14,400
cell which could happen if you had like a head or cell or some of you had multiple different types of

200
00:13:14,400 --> 00:13:19,050
cells for a single collection which you can maybe you have one cell that looks one way for a certain

201
00:13:19,050 --> 00:13:22,660
type of data and another cell it looks the other way you might have two collection B cells.

202
00:13:22,770 --> 00:13:28,860
In our case we only have one but we still need this statement here or rather that you don't even need

203
00:13:28,860 --> 00:13:29,510
an else statement.

204
00:13:29,510 --> 00:13:37,080
We could just say return and then we could say product cell because it would never get here if you made

205
00:13:37,080 --> 00:13:39,480
it through this portion here.

206
00:13:39,480 --> 00:13:39,710
OK.

207
00:13:39,720 --> 00:13:41,000
So great.

208
00:13:41,220 --> 00:13:45,810
We are creating a cell or two cuing it we're passing in the appropriate product so it updates the data

209
00:13:45,930 --> 00:13:49,400
and then returning that cell that looks fantastic.

210
00:13:49,890 --> 00:13:55,500
And we got our products collection view here which I think even though it says it's been set I think

211
00:13:55,560 --> 00:13:58,620
it's not probably set back in the storyboard here.

212
00:13:58,680 --> 00:14:04,080
Select your controller right click it and you see that product's collection is definitely not set it's

213
00:14:04,080 --> 00:14:05,230
lying to us.

214
00:14:05,550 --> 00:14:06,950
Let's drag it over there.

215
00:14:07,260 --> 00:14:08,280
OK.

216
00:14:08,280 --> 00:14:13,260
And then let's also make sure our cell has a reuse identifier so go to your product cell and it does

217
00:14:13,260 --> 00:14:15,960
not give us a reuse identifier.

218
00:14:16,050 --> 00:14:17,890
And we are going to call it product cell.

219
00:14:18,000 --> 00:14:20,860
You have to have this so the cells can be reused.

220
00:14:21,330 --> 00:14:21,820
OK.

221
00:14:21,930 --> 00:14:23,280
Let's go ahead and give this a spin.

222
00:14:23,360 --> 00:14:24,320
Let's just see where we are.

223
00:14:24,330 --> 00:14:28,410
See for even runs I'm feeling good about it so far.

224
00:14:28,410 --> 00:14:30,130
We could have forgotten something though.

225
00:14:30,660 --> 00:14:31,050
OK.

226
00:14:31,050 --> 00:14:33,020
Moment of Truth when we click one of these.

227
00:14:33,030 --> 00:14:34,250
We should see the next screen load.

228
00:14:34,260 --> 00:14:35,500
And it does show the appropriate data.

229
00:14:35,510 --> 00:14:42,610
I'm going to click hoodies and it's working so we've got our hoodies Dove soaps logo gray red gray and

230
00:14:42,610 --> 00:14:46,690
black so our data is definitely populating as expected.

231
00:14:46,990 --> 00:14:47,770
A couple of things.

232
00:14:47,770 --> 00:14:51,330
Is this coater swag is really annoying and it's not supposed to be there.

233
00:14:51,390 --> 00:14:54,550
The design that our designer gave us was just the arrow itself.

234
00:14:54,550 --> 00:14:56,350
And also there's not a title here.

235
00:14:56,350 --> 00:15:01,750
I think we need a title to show what kind of products it is and what kind of products we're showing

236
00:15:01,750 --> 00:15:02,260
rather.

237
00:15:02,440 --> 00:15:04,540
And shirts.

238
00:15:04,540 --> 00:15:07,400
So you know it looks pretty good and I kind of like it.

239
00:15:10,140 --> 00:15:12,000
Yeah yeah yeah yeah.

240
00:15:12,650 --> 00:15:13,070
I like it.

241
00:15:13,070 --> 00:15:14,710
So let's let's fix those couple of things.

242
00:15:14,710 --> 00:15:17,450
So what we'll do and this is empty which is great.

243
00:15:17,450 --> 00:15:21,510
So what we'll do is we'll get rid of this text here and then will set a title.

244
00:15:21,560 --> 00:15:23,310
So let's get the title first.

245
00:15:23,780 --> 00:15:32,010
So what we'll do is save this in the products we see when we're initializing this data.

246
00:15:32,010 --> 00:15:34,250
Here let's just go ahead and set the title.

247
00:15:34,260 --> 00:15:43,370
And that's easy as simple as saying navigation item Daut title equals we'll say category title so to

248
00:15:43,380 --> 00:15:45,510
grab the title of the navigation bar.

249
00:15:45,610 --> 00:15:49,380
OK all you have to do is grab navigation item that title and it knows how to find it and then you set

250
00:15:49,380 --> 00:15:51,830
it to the title here that is.

251
00:15:52,210 --> 00:15:53,520
That's really easy.

252
00:15:53,520 --> 00:15:58,410
The harder one is the button and you would think maybe you would do something like this navigation item

253
00:15:58,420 --> 00:16:03,540
that let's say back button right here or backbiter button item and then you know oh look at the title

254
00:16:03,540 --> 00:16:08,270
we can set the title like this equals you know let's say an empty string but it doesn't work.

255
00:16:08,310 --> 00:16:15,270
Unfortunately it does not recognize this because the the back button actually belongs to the previous

256
00:16:15,270 --> 00:16:16,120
few controller.

257
00:16:16,180 --> 00:16:19,050
OK it does not belong to this one and belongs to the previous one.

258
00:16:19,140 --> 00:16:21,550
So we have to do is actually go into categories visi.

259
00:16:21,770 --> 00:16:22,380
OK.

260
00:16:22,560 --> 00:16:27,080
And what we can do in the categories we see is we can just set it here and prepare for segue.

261
00:16:27,270 --> 00:16:28,050
All right.

262
00:16:28,050 --> 00:16:36,000
So we can right here create a bar button item so bar button equals you IVD bar button item you have

263
00:16:36,000 --> 00:16:37,580
to create a new one you can't modify it.

264
00:16:37,620 --> 00:16:40,590
Again like I said It's strange you think you could but you can't.

265
00:16:40,800 --> 00:16:41,770
So you create a new one.

266
00:16:41,850 --> 00:16:48,810
And what does one say bar button title will make it an empty string and now will say navigation item

267
00:16:50,070 --> 00:16:52,930
back bar button item equals bar button.

268
00:16:52,940 --> 00:16:55,260
Or place what's there with something new.

269
00:16:55,290 --> 00:16:56,510
OK.

270
00:16:57,480 --> 00:17:02,370
And you know I think I want to do this before I initialize anything just for good measure.

271
00:17:03,870 --> 00:17:04,380
Like so

272
00:17:08,000 --> 00:17:08,670
cool.

273
00:17:09,080 --> 00:17:11,140
So we've just created a bar button item.

274
00:17:11,300 --> 00:17:12,770
We said it with an empty title.

275
00:17:12,770 --> 00:17:17,460
And then what we've done is we've set the navigation item back bar button item to this new item here.

276
00:17:17,510 --> 00:17:24,860
So let's go ahead and see if that works shirts and says shirts at the top and has the backbone Kaino

277
00:17:24,870 --> 00:17:29,910
TX which is great hoodies so hoodies hats say hats.

278
00:17:29,990 --> 00:17:31,640
Prices are different everything this is really good.

279
00:17:31,640 --> 00:17:34,110
What you've done here is very important.

280
00:17:34,210 --> 00:17:34,780
OK.

281
00:17:34,910 --> 00:17:39,770
If you can if you don't have everything memorized that we've done in this series on this app then you're

282
00:17:39,770 --> 00:17:46,750
not likely to get a job as as an Iowa developer and the reason why is displaying data is so critical.

283
00:17:46,850 --> 00:17:49,970
OK and we've written what I call good clean code.

284
00:17:50,060 --> 00:17:52,930
So if you write code like this you'll you'll impress people.

285
00:17:53,120 --> 00:17:57,830
And what we've done is we've worked a table use reusable cells.

286
00:17:57,890 --> 00:18:02,620
We worked with collection use which our grid system again collection of can go horizontal if you want

287
00:18:02,620 --> 00:18:03,640
to swipe horizontally.

288
00:18:03,670 --> 00:18:10,840
You could let's say that you wanted Let's say that you wanted to be able to swipe horizontally here

289
00:18:10,870 --> 00:18:12,310
but swipe up and down here maybe this.

290
00:18:12,340 --> 00:18:17,920
Maybe we just had one page and this said hats and the said shirts what you could do is you could actually

291
00:18:17,920 --> 00:18:24,280
have a table view and each cell inside the table is actually a collection view OK with a horizontal

292
00:18:24,280 --> 00:18:24,650
scroll.

293
00:18:24,650 --> 00:18:26,110
So the table view goes vertical.

294
00:18:26,110 --> 00:18:27,840
But the collection below goes horizontal.

295
00:18:27,940 --> 00:18:32,290
And so you could have this row here on the table you cell which is a collection of you it goes from

296
00:18:32,290 --> 00:18:34,300
left to right left or right left or right.

297
00:18:34,360 --> 00:18:38,470
And that's how you would build something that goes up and down and left and right which is really cool

298
00:18:38,470 --> 00:18:39,060
of course.

299
00:18:39,190 --> 00:18:43,690
The collection itself can also do that functionality so you can do a collection view within a collection

300
00:18:43,690 --> 00:18:44,330
view.

301
00:18:44,410 --> 00:18:47,770
And we did a grid spacing here the spacing was automatic for us.

302
00:18:47,770 --> 00:18:50,980
You can change the spacing you can change the layouts and do some other nifty things.

303
00:18:50,980 --> 00:18:54,240
We didn't even begin to cover all of that here but you can change all that.

304
00:18:54,520 --> 00:19:00,400
And this has really come together you've learned how to host data in a data service using the singleton

305
00:19:00,400 --> 00:19:01,050
pattern.

306
00:19:01,060 --> 00:19:07,510
OK one instance of this class in memory you've also learned the basics of implementing the delegate

307
00:19:07,510 --> 00:19:12,660
pattern which is you have classes implement some type of protocol.

308
00:19:12,700 --> 00:19:14,170
And I will abide by these rules.

309
00:19:14,170 --> 00:19:18,880
And once those protocols are implemented X code will force you to implement the code needed for it such

310
00:19:18,880 --> 00:19:23,300
as sell for item index path etc. and then you implement those things.

311
00:19:23,320 --> 00:19:27,740
You have to make sure you set the data source and delegate on your table view or collection of view.

312
00:19:27,760 --> 00:19:31,730
Otherwise your app will not run appropriately.

313
00:19:31,760 --> 00:19:35,140
A lot of new developers do that so you'll learn a lot of things here.

314
00:19:35,140 --> 00:19:38,860
This is the basis and foundation of what you're going to do whenever working with data.

315
00:19:38,980 --> 00:19:41,160
And we've taught you everything here the right way.

316
00:19:41,260 --> 00:19:45,310
OK the Apple way and I'm I'm happy.

317
00:19:45,310 --> 00:19:45,910
I think it's good.

318
00:19:45,910 --> 00:19:47,290
So congratulations.

319
00:19:47,440 --> 00:19:48,760
This is good stuff here.

320
00:19:48,850 --> 00:19:53,950
And let's move on and forward two other amazing apps Mark Price at deps slopes dot com.

321
00:19:53,950 --> 00:19:54,690
See you next time.
