1
00:00:00,210 --> 00:00:01,300
Welcome back again.

2
00:00:01,320 --> 00:00:06,940
In this lesson we're going to talk about custom table view sales and in doing that I'm actually going

3
00:00:06,940 --> 00:00:13,780
to do a quick recap of a lot of concepts that we have done both in this section and our previous sections.

4
00:00:13,830 --> 00:00:19,650
So I will try to make a very tiny application that uses a lot of things that we have done in the past.

5
00:00:19,740 --> 00:00:25,870
So the application that I develop is essentially like a real estate property search application that

6
00:00:25,920 --> 00:00:31,220
you have a table view that shows you a lot of different properties and you can search between them.

7
00:00:31,320 --> 00:00:34,040
I believe the search part of it to the next lesson.

8
00:00:34,050 --> 00:00:40,230
But in this lesson we learn how to make the property population how we add so many different properties

9
00:00:40,500 --> 00:00:45,770
and then how do we customize asset to show all of those details about each property.

10
00:00:46,200 --> 00:00:47,630
So that's going to explode.

11
00:00:48,120 --> 00:00:53,910
And in here I'm going to start a new application from this point on within the application as sometimes

12
00:00:53,910 --> 00:00:58,920
I make a single of your application and I have an add a table view to it and sometimes I'll make a single

13
00:00:59,100 --> 00:01:02,770
application I will make a table view controller in it.

14
00:01:02,850 --> 00:01:08,670
Both of them would be kind of identical but depending on your needs you might need either of the two.

15
00:01:08,670 --> 00:01:14,380
So it's makes sense that I show you both of them several times so we have a better grasp on them.

16
00:01:14,430 --> 00:01:23,990
So for no I say a single viewer application custom so custom tables set up and this is my application

17
00:01:24,050 --> 00:01:30,230
and the moment it shows up I'm going to head into the storyboard and say for this one maybe we make

18
00:01:30,260 --> 00:01:32,120
a table view controller.

19
00:01:32,420 --> 00:01:37,850
So I'm going to add table of your controller if I remember this is the one that built into it has a

20
00:01:37,850 --> 00:01:41,460
table view and built into that it has a table view cell.

21
00:01:41,720 --> 00:01:50,120
But this cell this time I don't want to use it as it is right now which is using one of the basic pre-existing

22
00:01:50,120 --> 00:01:50,780
templates.

23
00:01:50,780 --> 00:01:52,390
I don't want to use either of these.

24
00:01:52,490 --> 00:01:58,670
I want to make my own template under the table they want to make for myself it essentially has these

25
00:01:58,670 --> 00:01:59,780
different parameters.

26
00:01:59,780 --> 00:02:01,740
It has a title on the top.

27
00:02:01,820 --> 00:02:03,970
It has a description in the center.

28
00:02:03,980 --> 00:02:10,010
And since this is an application for real estate it also shows me the number of the bedrooms and the

29
00:02:10,010 --> 00:02:12,710
number of the bathrooms on that property.

30
00:02:12,710 --> 00:02:15,720
So let's go ahead and design a cell like that.

31
00:02:15,740 --> 00:02:17,330
I'm going to select my table view.

32
00:02:17,330 --> 00:02:24,460
I'm gonna go up here into my table of use dimensions and say each row is a height is 128 unit.

33
00:02:24,560 --> 00:02:26,240
So it's actually quite larger.

34
00:02:26,420 --> 00:02:32,060
And I could temporary change the background car of the cell so we could see it more clearly.

35
00:02:32,180 --> 00:02:39,260
Maybe if I make it like that it shows me that this area there kind of brown area is where my cell is

36
00:02:39,260 --> 00:02:40,200
going to be.

37
00:02:40,310 --> 00:02:43,100
Now a cell view is like any other view.

38
00:02:43,100 --> 00:02:47,200
You could just add any objects tweet as a sub for you if you want it.

39
00:02:47,270 --> 00:02:53,150
So for instance I could go ahead in here and say I have a label I'm going to wrap it up here say this

40
00:02:53,150 --> 00:02:59,780
label on the very top somewhere like there will be my title the main title of the property then I'm

41
00:02:59,780 --> 00:03:06,290
going to have a text view so I'm going to add another one of these which is here a text you in here

42
00:03:06,530 --> 00:03:11,960
and a lot of smaller of course I'm going to come back to these and clean things up I'm going to add

43
00:03:11,960 --> 00:03:19,370
two more labels so there is a label here on the lower left corner and they that label on the lower right.

44
00:03:19,370 --> 00:03:25,040
CORNISH Now let's go ahead and zoom into this thing and we can start modifying things.

45
00:03:25,040 --> 00:03:26,930
The first thing is this label on the top.

46
00:03:26,960 --> 00:03:28,680
I want it to be centered.

47
00:03:28,730 --> 00:03:30,290
I want it to be a lot larger.

48
00:03:30,320 --> 00:03:35,150
Maybe want its font to also be quite heavy something like this.

49
00:03:35,150 --> 00:03:40,610
So for instance this is the one that shows me maybe somebody who is selling their property they going

50
00:03:40,610 --> 00:03:48,110
to title it house on the terror street maybe something like that.

51
00:03:48,110 --> 00:03:49,590
So that's the title of it.

52
00:03:49,610 --> 00:03:55,400
Then there's a better description for it and description for it says maybe along the lines of this is

53
00:03:55,430 --> 00:04:02,270
a beautiful neighborhood or anything that you can imagine someone would write in a description for a

54
00:04:02,270 --> 00:04:03,350
property.

55
00:04:03,350 --> 00:04:05,830
I'm going to replace it somewhat about here

56
00:04:08,560 --> 00:04:09,210
like that.

57
00:04:09,250 --> 00:04:11,140
So they're all set properly.

58
00:04:11,140 --> 00:04:16,000
Then these two labels are meant to show us the number of the bedrooms on this property and the number

59
00:04:16,000 --> 00:04:17,230
of the bathrooms.

60
00:04:17,230 --> 00:04:21,970
I'm not going into the details of developing a real estate application just yet.

61
00:04:22,030 --> 00:04:27,020
We are assuming that these are for residential places and they have bedrooms and they have bathrooms

62
00:04:27,020 --> 00:04:29,570
so that's all we care about right now.

63
00:04:29,620 --> 00:04:33,080
So we have not and maybe make it a little bit wider.

64
00:04:33,160 --> 00:04:40,360
Something like that or something one of the hundreds maybe both of these a little bit smaller so they're

65
00:04:40,360 --> 00:04:49,060
not as a prominence and maybe both of them are having different colors such as dark gray colors something

66
00:04:49,060 --> 00:04:49,700
like that.

67
00:04:49,810 --> 00:04:50,770
I'm for a description.

68
00:04:50,770 --> 00:04:52,440
I'm gonna throw up the background color.

69
00:04:52,840 --> 00:04:56,250
I don't want that OK.

70
00:04:56,300 --> 00:05:02,580
And of course for the cell itself I'm going to make its mind going to be something like a group table

71
00:05:02,580 --> 00:05:02,840
view.

72
00:05:02,850 --> 00:05:08,030
So it's actually quite clean and nice and it shows me all the details that I want.

73
00:05:08,040 --> 00:05:13,700
Then next thing I have to do is I'm going to have to set the separator line so I can see them clearly.

74
00:05:13,770 --> 00:05:20,010
I'm going to go in here and say My separator is a single line and that single line has a color maybe

75
00:05:20,010 --> 00:05:21,850
like this one a bluish color.

76
00:05:21,860 --> 00:05:28,400
They can clearly see I usually like to set my custom separator in sets of 15 and 15.

77
00:05:28,470 --> 00:05:30,220
So there's a little distance in here.

78
00:05:30,240 --> 00:05:31,710
Little gap on the other side.

79
00:05:32,190 --> 00:05:38,460
And you have to set the kind of strains for your elements within your cell simply because the table

80
00:05:38,460 --> 00:05:44,340
view as you set it it will always have a height of one hundred twenty eight but the veto of it will

81
00:05:44,340 --> 00:05:47,490
depend on the size of the device that you're using.

82
00:05:47,490 --> 00:05:53,730
So if I'm designing an iPhone 8 as I'm doing it in here and I write an iPhone 8 we obviously see the

83
00:05:53,730 --> 00:05:55,020
very same thing.

84
00:05:55,020 --> 00:06:00,360
But if you want to be run this application on iPhone 10 as it is the case in here then we'll end up

85
00:06:00,360 --> 00:06:03,630
seeing a different arrangement of the elements.

86
00:06:03,780 --> 00:06:06,750
So it makes sense that they set all the constraints manually.

87
00:06:07,080 --> 00:06:12,130
So to do that I'm going to go ahead and say this object in here it has a top US space.

88
00:06:12,170 --> 00:06:14,190
It has a leading space.

89
00:06:14,220 --> 00:06:17,740
It has a trailing space and it has a height.

90
00:06:17,820 --> 00:06:22,680
There is an icon set the height is simply because I know the height of the cell it will always be the

91
00:06:22,680 --> 00:06:23,400
same.

92
00:06:23,430 --> 00:06:25,090
So proportional to that.

93
00:06:25,110 --> 00:06:26,430
This is OK.

94
00:06:26,640 --> 00:06:33,810
Then I'm going to go ahead and do the same thing for my other objects including the text edit or text

95
00:06:33,810 --> 00:06:36,280
view set the height for it.

96
00:06:36,390 --> 00:06:39,850
Then I'm going to say for this object it has a VIT.

97
00:06:40,140 --> 00:06:41,720
It has a vertical spacing.

98
00:06:41,760 --> 00:06:47,340
It has a leading is facing and it has a bottom is facing and the same thing in here.

99
00:06:47,340 --> 00:06:55,080
It has a width it has a trailing a space a vertical of space and a button space and that's all I have

100
00:06:55,080 --> 00:06:56,790
to do to set all the kind of thing.

101
00:06:56,820 --> 00:06:58,800
So they always look the same.

102
00:06:58,980 --> 00:07:05,250
Now the next thing that is quite important is how are we going to access these different items.

103
00:07:05,340 --> 00:07:12,600
To do that we need to have a subclass for my table view cell which currently doesn't have any class

104
00:07:12,630 --> 00:07:15,570
and is using the default UI table view cell.

105
00:07:15,960 --> 00:07:24,360
So they go ahead and say fine new command n I want a Coke with each class of the type you I table view

106
00:07:24,390 --> 00:07:32,580
cell and I want to call this one my table view cell all is property table view cell depending on what

107
00:07:32,730 --> 00:07:38,580
you are doing in a larger application it makes sense that the names are more definitive but in our smaller

108
00:07:38,580 --> 00:07:44,310
applications such as this one it doesn't really matter in the table view cell subclass we don't really

109
00:07:44,310 --> 00:07:49,230
need to do anything we need to keep both of these functions but what we really need to do is we need

110
00:07:49,230 --> 00:07:56,220
to add all of our outlets so to do that I'm going to head back to a storyboard select my cell and say

111
00:07:56,220 --> 00:08:03,450
my cell has this one as a class for its property table view set and once they do that I could go ahead

112
00:08:03,450 --> 00:08:10,270
to my assistant window and load the right object if it doesn't load it automatically which sometimes

113
00:08:10,300 --> 00:08:12,720
exclude doesn't you have to manually load it.

114
00:08:12,720 --> 00:08:14,830
So I think that's the case with me now.

115
00:08:14,970 --> 00:08:21,390
So I want to go in here and say it in a sort of the automatic make it manual and in here load property

116
00:08:21,390 --> 00:08:29,590
table view said I'd load this one I'm going to go ahead and say this object on the top this one Let's

117
00:08:29,600 --> 00:08:35,040
call this one may maybe top labor the text.

118
00:08:35,100 --> 00:08:43,030
I'm gonna call it this corruption text view the left one here.

119
00:08:43,030 --> 00:08:56,070
I'm going to call it bedroom's label and dab on the last one I'm going to call it bathrooms labor.

120
00:08:56,220 --> 00:09:02,340
So we now have a new class that can access all the outlets from my newly created set.

121
00:09:02,400 --> 00:09:09,300
So let's go ahead into our actual story boiler actual fight which is this one make it our initial view

122
00:09:09,300 --> 00:09:15,080
controller just like every other time that you had to do it in you and I have to assign a class for

123
00:09:15,080 --> 00:09:15,750
here as well.

124
00:09:15,760 --> 00:09:18,000
So I'm gonna say command and in here.

125
00:09:18,030 --> 00:09:25,810
That's going to be a you I table view controller and I'm going to call it my table view controller.

126
00:09:25,860 --> 00:09:28,680
Yeah I've done this several times before already.

127
00:09:28,710 --> 00:09:33,520
Of course you know we don't need the view controller anymore because nobody's really using that someone

128
00:09:33,540 --> 00:09:39,150
actually delete this one and I'm going to head to the storyboard and say the class for this table view

129
00:09:39,150 --> 00:09:44,370
controller is actually going to be my table view controller.

130
00:09:44,730 --> 00:09:50,730
And if you remember table of your controllers by default they had a lot of methods methods that we would

131
00:09:50,730 --> 00:09:55,160
need to populate their content number of sections number of rows.

132
00:09:55,320 --> 00:10:03,760
And the only tool that we actually needed are these to the number of rows and also sell for raw at index

133
00:10:03,760 --> 00:10:04,850
spot which is here.

134
00:10:04,860 --> 00:10:08,460
The formatting is confusing me for a second cell for row.

135
00:10:08,460 --> 00:10:11,120
I didn't expect everything else I can drop for now.

136
00:10:11,760 --> 00:10:18,180
So here we have now these two functions that we have to use them to populate our table view.

137
00:10:18,300 --> 00:10:24,120
So later on I'm going to write an actual data class that is going to hold on to my information but for

138
00:10:24,120 --> 00:10:28,950
now because I just want to be able to see what I have done with my table view I'm going to go ahead

139
00:10:28,950 --> 00:10:33,500
and say let's see our table view always shows us 10 sales.

140
00:10:33,660 --> 00:10:39,640
So that's just a random number it shows as a static number of 10 sounds at all times the memory format

141
00:10:39,750 --> 00:10:41,150
everything nice and tidy.

142
00:10:41,790 --> 00:10:48,360
And then for the cell at row I'm going to have to come up with some random or just you know static values

143
00:10:48,810 --> 00:10:55,380
I'm going to say cell that becomes my table view Q reusing identifier I don't have an identifier just

144
00:10:55,410 --> 00:11:01,980
yet so I'm going to go to my cell say My cell is actually having an identifier that is if I selected

145
00:11:02,010 --> 00:11:07,100
properly it is cell I.

146
00:11:07,740 --> 00:11:13,410
So that's the idea for my cell and then I come in here and say that's the idea for it for index map

147
00:11:13,770 --> 00:11:20,880
but then I don't want it to be of the type that is the default type which is you a table view cell I

148
00:11:20,880 --> 00:11:28,140
want it to be after type property table view cell I'm going to go ahead in here and say as property

149
00:11:29,010 --> 00:11:30,270
table view cell.

150
00:11:30,600 --> 00:11:35,730
So the cells that they have in here I know them to be of the type property table of your cell.

151
00:11:35,730 --> 00:11:42,480
So I'm going to get it to be of that type the moment we do that if for a second you forget this entire

152
00:11:42,480 --> 00:11:43,570
part.

153
00:11:43,770 --> 00:11:49,140
This is like this is going to produce an error or not but if we could assume it to be like that it means

154
00:11:49,170 --> 00:11:57,630
we have a cell of this type and that type gives us access to all of these guys top labor description

155
00:11:57,780 --> 00:11:59,570
of bedrooms and bathrooms.

156
00:11:59,570 --> 00:12:07,140
Talk is no different than using any other class they could come in here and say well said the cell dot

157
00:12:07,170 --> 00:12:18,930
top label that text to become let's say title and then sell that description view that text make it

158
00:12:18,930 --> 00:12:29,760
to be this is a description and then sell dot bedrooms label let's just give it a number or bedrooms

159
00:12:29,820 --> 00:12:36,930
something like that and then sell that bathroom label becomes let's say the same thing.

160
00:12:38,220 --> 00:12:44,670
So when you do this you essentially get all of those variables from your cell to be populated in here

161
00:12:45,090 --> 00:12:52,140
of course in this case I'm just doing it a statically for ten of them and I forgot to add the two texts

162
00:12:52,140 --> 00:12:53,750
in here as I always do.

163
00:12:54,500 --> 00:13:00,420
And if you're on the application now we should be able to see this application showing us 10 cells that

164
00:13:00,420 --> 00:13:06,930
they are all populated but they're populated with the same set of information which is obviously not

165
00:13:06,930 --> 00:13:11,030
what we want but it shows us we're going in the right direction at least.

166
00:13:11,760 --> 00:13:16,920
So another app is know that I can see that there is now one title this is a description so on and so

167
00:13:16,920 --> 00:13:19,080
forth for ten of them.

168
00:13:19,080 --> 00:13:24,190
Now we need to populate our data and this is really something that we have done before.

169
00:13:24,380 --> 00:13:25,770
This is nothing new about it.

170
00:13:25,770 --> 00:13:27,430
This is not about the table views.

171
00:13:27,510 --> 00:13:33,770
This is merely about using classes and using arrays to produce data for application.

172
00:13:34,170 --> 00:13:38,760
So the first thing I'm gonna do is I'm going to make a new shift file this shift while I'm going to

173
00:13:38,760 --> 00:13:45,540
call it property and the property is actually going to hold on to my property class.

174
00:13:45,570 --> 00:13:48,490
So it's going to be a class property.

175
00:13:48,490 --> 00:13:54,270
So this is each of the listings that people they place on your application essentially.

176
00:13:54,300 --> 00:14:01,140
So for each of them I have went to have a value and let's have title which is a string I'm going to

177
00:14:01,140 --> 00:14:08,830
have a valuable description which is again a string I have a variable let's call it bedrooms.

178
00:14:09,000 --> 00:14:15,950
This one I'm going to make it an integer and a value of our bathrooms which is again an integer.

179
00:14:16,110 --> 00:14:22,110
And I think that's quite enough for my application on this test that we are doing in a real life application

180
00:14:22,110 --> 00:14:25,040
you might have so many other pieces of information.

181
00:14:25,170 --> 00:14:28,180
But I think for us this would be this would be enough.

182
00:14:28,290 --> 00:14:32,190
So the next thing I want to do is I'm going to have to write and in it and in the end it I'm going to

183
00:14:32,190 --> 00:14:40,520
say input title which is a string and input description which is also a string I'm gonna get an input

184
00:14:40,530 --> 00:14:48,250
bits which is also which is an integer an input that's which is an integer and based on that you're

185
00:14:48,270 --> 00:14:56,490
going to populate everything I'm going to say title is the input title and description is the input

186
00:14:56,490 --> 00:15:06,600
description bedrooms is the input bits and bathrooms on the input that's and that's all we have to do

187
00:15:06,600 --> 00:15:07,050
in here.

188
00:15:07,080 --> 00:15:12,870
So we have a new cast this new class has an initialize there initialized as based on the four values

189
00:15:12,870 --> 00:15:17,020
that the offer it makes a new property for us.

190
00:15:17,340 --> 00:15:22,500
Now the next thing we have to do is we have to assume that our data is going to be stored somewhere

191
00:15:22,860 --> 00:15:28,410
and this is something we'll see in far more advanced details in the future but for now we'll actually

192
00:15:28,410 --> 00:15:34,470
place my data within an array of a new class and you might be wondering why don't we put it right here

193
00:15:34,470 --> 00:15:35,280
in this class.

194
00:15:35,280 --> 00:15:40,380
You very well could do that but there is actually another very good practice a better practice is to

195
00:15:40,380 --> 00:15:46,260
separate your objects as much as you can your model as much as you can see your data is in a separate

196
00:15:46,260 --> 00:15:46,800
place.

197
00:15:46,860 --> 00:15:50,710
So if you want to access it and read it you can read it from a separate location.

198
00:15:50,760 --> 00:15:58,940
So I'm going to say I have a new find this new find I'm going to call it to be my data and obviously

199
00:15:58,940 --> 00:16:02,360
it holds a class called class.

200
00:16:02,420 --> 00:16:09,620
My data doesn't have a super class and the only thing I want to have for you here I want to have one

201
00:16:09,620 --> 00:16:19,220
value event which is called properties array which is an array of property property.

202
00:16:19,280 --> 00:16:21,520
So that's the only thing I want to have for it.

203
00:16:21,830 --> 00:16:28,790
Now since I don't want to constantly re initialize an object from my date on I want to be able to use

204
00:16:28,790 --> 00:16:32,960
it globally everywhere I'm going to make this guy to be a static value.

205
00:16:33,350 --> 00:16:38,170
So it's a static valuable called properties array that we can access it wherever we want.

206
00:16:38,180 --> 00:16:41,690
And we only initialize it once once we have it.

207
00:16:41,690 --> 00:16:44,100
We can use it forever if we want to use it.

208
00:16:44,120 --> 00:16:47,490
So that's all we have to do for our class my data.

209
00:16:47,510 --> 00:16:50,990
Now the next thing is how are we going to populate the information.

210
00:16:50,990 --> 00:16:57,920
Harvey going to make our properties in a real life application these properties would be posted by many

211
00:16:57,920 --> 00:16:59,060
many users.

212
00:16:59,060 --> 00:17:00,430
We don't have that luxury.

213
00:17:00,460 --> 00:17:04,300
Yes I'm actually going to go ahead and make some dummy information here.

214
00:17:04,360 --> 00:17:11,600
And when I go ahead I'm making you find I'm going to call this one populate or maybe dummy populate

215
00:17:11,960 --> 00:17:17,750
because these are the dummy information we don't really have them from some source or nobody's actually

216
00:17:17,750 --> 00:17:18,470
entering them.

217
00:17:18,560 --> 00:17:20,990
We're just assuming there would exist at some point.

218
00:17:21,280 --> 00:17:31,400
So in here I have a class called dummy populate the dummy populate essentially has only one function.

219
00:17:31,560 --> 00:17:34,350
That's a function called populate.

220
00:17:34,370 --> 00:17:37,040
These are the dummies that you're going to produce in here.

221
00:17:37,580 --> 00:17:43,400
And since I'm going to use this function in any of the other classes I'm going to have to make this

222
00:17:43,430 --> 00:17:49,260
a class function because I don't want to initialize this dummy populate as an object.

223
00:17:49,340 --> 00:17:52,440
I just want to use this particular function from it.

224
00:17:52,460 --> 00:17:58,190
This would be very similar to copying this function going to a table a view controller and placing it

225
00:17:58,190 --> 00:17:59,500
somewhere up here.

226
00:17:59,510 --> 00:18:01,000
We could very well do that.

227
00:18:01,010 --> 00:18:06,710
The simple reason why we don't do it is because it's a better design to have everything separate from

228
00:18:06,710 --> 00:18:07,390
each other.

229
00:18:07,460 --> 00:18:14,120
This way my table view controller can focus on only taking care of the table view and my populate takes

230
00:18:14,120 --> 00:18:19,250
care of the population of the data and everybody else takes care of their own task essentially.

231
00:18:19,470 --> 00:18:20,430
Somebody delete that.

232
00:18:20,450 --> 00:18:21,860
Go back to my dummy populate.

233
00:18:21,890 --> 00:18:23,600
I have a class function.

234
00:18:23,600 --> 00:18:30,290
The first thing I'm where doing my class function is I'm going to say my data dot array becomes an empty

235
00:18:30,290 --> 00:18:33,500
one because we want to start adding stuff to it.

236
00:18:33,500 --> 00:18:41,270
Then I'm going to go ahead and say let let's call this one house one that is going to be a property

237
00:18:41,780 --> 00:18:45,260
and that property needs all these foreign pieces of information.

238
00:18:45,740 --> 00:18:54,650
So I'm going to go ahead and say the title is house on the terrace the streets and the description is

239
00:18:54,900 --> 00:19:00,570
this is a beautiful house.

240
00:19:00,740 --> 00:19:03,230
They'll built or something like that.

241
00:19:03,260 --> 00:19:05,870
I don't really know what they post in there.

242
00:19:05,900 --> 00:19:09,400
The number of bedrooms is three the number of bathrooms is say 1.

243
00:19:09,800 --> 00:19:18,880
And then I'm gonna say this guy my at my data that's properties that append house 1 tweets.

244
00:19:19,160 --> 00:19:21,860
Then I'm going to copy this process one more time.

245
00:19:22,130 --> 00:19:24,930
And since these are my dummies I'm only going to two times.

246
00:19:24,980 --> 00:19:31,660
So the next one is going to be are lists view apartment.

247
00:19:32,990 --> 00:19:34,250
If that's how you spell it.

248
00:19:34,640 --> 00:19:44,680
And then I'm going to say beautiful building with nice views and it has only one bedroom and one bathroom.

249
00:19:44,810 --> 00:19:47,690
And that is going to be added in here as well.

250
00:19:47,990 --> 00:19:54,460
So you're adding both of those to our properties array and that's all I want to do with my populate.

251
00:19:54,530 --> 00:19:59,900
If you wanted to you could add more of these or you could write a text field set off you know objects

252
00:19:59,900 --> 00:20:05,930
in a new view controller where your user can actually add more of these to your array if you will do

253
00:20:05,930 --> 00:20:11,390
a lot more of these when we talk about data which is coming up in a few sections but for now we're just

254
00:20:11,390 --> 00:20:12,860
gonna make two dummies.

255
00:20:12,860 --> 00:20:19,130
So by the time this function is called our properties array will have two objects in it.

256
00:20:19,130 --> 00:20:21,970
So the last thing we have to do is actually rather simple.

257
00:20:21,980 --> 00:20:27,380
I have to go to my table of your controller in my view did look when the view actually loads for the

258
00:20:27,380 --> 00:20:34,480
first time I'm going to go ahead in here and say dummy populate dot populate.

259
00:20:34,550 --> 00:20:36,470
So make all of those objects.

260
00:20:36,470 --> 00:20:40,940
So by calling this function you're essentially making all of these things happen.

261
00:20:41,210 --> 00:20:47,950
So by now we have the array ready to us if I have the array ready to do me I can simply do this.

262
00:20:47,960 --> 00:20:53,810
I could go ahead and say number of rows are actually going to be made out to dot array that counts.

263
00:20:54,200 --> 00:20:59,670
So instead of just you know putting 10 in there I'm going to say the number that I actually have in

264
00:20:59,670 --> 00:21:04,620
my array and the next thing I'm going to do in here is actually very very simple in here I'm going to

265
00:21:04,620 --> 00:21:09,800
go ahead and say let this property to be.

266
00:21:09,960 --> 00:21:16,200
I'm going to say my data dot array and from the array I'm going to get the object that index part the

267
00:21:16,230 --> 00:21:23,730
draw because this cell is showing us either the first one or the second one from these two objects.

268
00:21:23,730 --> 00:21:30,090
These these two objects in the area or this array so I'm going to go in here and say well wherever you

269
00:21:30,090 --> 00:21:30,300
are.

270
00:21:30,300 --> 00:21:33,140
Find out which property you want to show.

271
00:21:33,270 --> 00:21:41,760
And if you found the property for the top label say that property dot title for the description say

272
00:21:41,790 --> 00:21:42,970
that property.

273
00:21:42,980 --> 00:21:50,170
That description for the number of the bedrooms say that property dot bedrooms.

274
00:21:50,220 --> 00:21:51,920
So we have to format it.

275
00:21:51,960 --> 00:21:59,080
I'm going to go ahead and say let's format it like this and paint.

276
00:21:59,100 --> 00:22:03,530
Yes say bedrooms or maybe like that better.

277
00:22:03,750 --> 00:22:07,590
I'm led do the same thing for the bathroom I'm going to say it is actually like this.

278
00:22:07,620 --> 00:22:12,970
It has a formatting of this property that bathrooms.

279
00:22:13,110 --> 00:22:16,790
And it says bathrooms and that's about it.

280
00:22:16,800 --> 00:22:22,170
We have a custom table view so that we have it here as a as a class.

281
00:22:22,170 --> 00:22:25,800
And that one is connected to an actual cell in a storyboard.

282
00:22:25,830 --> 00:22:32,640
We have our data being populated in year from a certain type of property and wants to become part table

283
00:22:32,640 --> 00:22:34,950
of your controller we populate those.

284
00:22:34,980 --> 00:22:41,370
We find the number of those two and assume the number of cells in our table view and for each of the

285
00:22:41,370 --> 00:22:42,870
cells in our table view.

286
00:22:42,900 --> 00:22:49,460
If you find that particular property and we use that to show the different values of our outlets in

287
00:22:49,450 --> 00:22:50,760
our actual cell.

288
00:22:50,760 --> 00:22:56,430
So let's go ahead and run this application if it all goes well we should be able to see two cells each

289
00:22:56,430 --> 00:23:01,920
cell showing us some of the details and that's happening in here and we are seeing two of the cells

290
00:23:01,920 --> 00:23:02,640
in here.

291
00:23:02,640 --> 00:23:09,240
These are custom sense you could imagine that for the cells you can have multiple takes viewers Labor's

292
00:23:10,050 --> 00:23:16,380
image you use for whatever purpose that you are trying to make them look like you could actually extend

293
00:23:16,380 --> 00:23:21,780
the table view to have more you know detail is in here if you want to make an application such as a

294
00:23:21,780 --> 00:23:27,670
Twitter application that each of the cells on their own they lose so many many different things.

295
00:23:27,780 --> 00:23:34,290
The advantage of the table view is that these cueing feature that gets rid of the already used cells.

296
00:23:34,350 --> 00:23:40,800
So that was how to use a table of your cell said let's keep it up to here and move on to our next lesson.
