1
00:00:00,470 --> 00:00:03,090
So I'll come back again in this exercise.

2
00:00:03,090 --> 00:00:09,780
You are required to make a vague sharp sharp which is essentially something you have done in the past

3
00:00:09,780 --> 00:00:14,910
that has a list of differing car design availability and what not.

4
00:00:14,930 --> 00:00:23,070
But this time you're trying to use classes subclasses Nom's delegation's at any time and convenience

5
00:00:23,100 --> 00:00:30,630
is on essentially everything we learnt in this past past section something that you know I should mention

6
00:00:30,630 --> 00:00:37,200
is that you could choose to just watch me doing this this exercise simply because a lot of the things

7
00:00:37,200 --> 00:00:44,540
I'm doing in this exercise are not necessarily needed for the purpose of making an app like this but

8
00:00:44,560 --> 00:00:50,360
they want to go through them simply because I wanted to make sure that we have a review over them by

9
00:00:50,370 --> 00:00:51,310
the end of it.

10
00:00:51,330 --> 00:00:59,070
We should have something similar to this that you have a list of the cars that you can filter them through

11
00:00:59,400 --> 00:01:06,210
available ones the ones that are out there was a car and we had to repair the cars that are seen on

12
00:01:06,210 --> 00:01:12,380
cars or the cars or trucks and essentially you can think of this as an app that does either no managers

13
00:01:12,380 --> 00:01:19,230
that I can't for for a for a rental shop that they have available because they have out cars they have

14
00:01:19,230 --> 00:01:22,180
repaired cars and different types of cars.

15
00:01:22,270 --> 00:01:28,590
And unfortunately because we haven't yet learned things such as a table view or your collection views

16
00:01:29,170 --> 00:01:31,570
the display of them is a little bit ugly right now.

17
00:01:31,570 --> 00:01:36,870
But everything else that we do is quite you know important and it's quite relevant.

18
00:01:37,050 --> 00:01:43,050
So that's that's the plan if you want to pause the video for a few seconds.

19
00:01:43,200 --> 00:01:48,630
You can get south on your own and try to make it on your own or if you can just start you know watching

20
00:01:48,630 --> 00:01:56,400
my solution simply because like I said it's just it's just making sure that we have another review of

21
00:01:56,400 --> 00:01:56,970
everything.

22
00:01:56,970 --> 00:02:00,160
So let's get started in a few seconds

23
00:02:03,410 --> 00:02:04,730
so I'm going to go to school.

24
00:02:04,900 --> 00:02:07,700
I'm going to start thinking your swift project.

25
00:02:07,810 --> 00:02:08,710
Mike.

26
00:02:08,810 --> 00:02:14,020
Iowa's application called the shop hop

27
00:02:17,690 --> 00:02:20,960
that a place you're not.

28
00:02:20,960 --> 00:02:22,240
Let's get this thought.

29
00:02:22,570 --> 00:02:28,750
And the first thing I want to do is I want to go ahead and add a new class when I say coquetries class

30
00:02:28,880 --> 00:02:30,780
of that type.

31
00:02:30,890 --> 00:02:40,440
It's called it color of that type and a subject and seems sweet sweet swift like would essentially remove

32
00:02:40,450 --> 00:02:54,050
the subject not vehicle class has a few set of variables one of them is a name I call it name which

33
00:02:54,050 --> 00:02:55,140
is a string.

34
00:02:55,520 --> 00:02:59,950
And then it has a vowel color which is a U.

35
00:02:59,980 --> 00:03:02,140
I call it.

36
00:03:02,690 --> 00:03:10,770
And then I have let's say Max a year and that's going to be an integer.

37
00:03:11,060 --> 00:03:15,370
And then when I have something that I call it a state for starters.

38
00:03:15,410 --> 00:03:22,930
And that's essentially one of the three current ways out available liberal or three pairs and to do

39
00:03:22,970 --> 00:03:24,010
that I'm actually going to make.

40
00:03:24,020 --> 00:03:34,840
And you know so when I go in here and say let's have a swift file that is konked in arms and this enormous

41
00:03:34,840 --> 00:03:38,040
call is to be a state.

42
00:03:38,490 --> 00:03:42,240
It's going to have a case available.

43
00:03:42,560 --> 00:03:47,900
Case out on a case repairs.

44
00:03:47,990 --> 00:03:54,410
So that's my you know keep something in mind that this would end up changing this enough because it

45
00:03:54,410 --> 00:03:56,490
needs to have a type.

46
00:03:56,580 --> 00:04:03,550
It also needs to be chase I'd about table but I don't want to do that right now even though I enjoyed

47
00:04:03,550 --> 00:04:06,920
it because that's the process of making up.

48
00:04:07,070 --> 00:04:11,220
When you start working on a project you don't necessarily know what's coming up.

49
00:04:11,240 --> 00:04:16,590
And it would be it would then be really useful of me to give you the solutions right away.

50
00:04:16,660 --> 00:04:19,730
I want to wait for the time to come to face an issue.

51
00:04:19,730 --> 00:04:27,130
Explain why that issue happened and why we have to change our enumerators so or anything essentially.

52
00:04:27,140 --> 00:04:28,370
So let's go to I'll be here.

53
00:04:28,370 --> 00:04:35,960
I'm going to say well now my Racheal has a variable called the status and the status is of the type

54
00:04:35,970 --> 00:04:37,560
V here state.

55
00:04:37,580 --> 00:04:41,070
So now I have another value in here.

56
00:04:41,270 --> 00:04:43,690
Now let's go ahead and write in it.

57
00:04:43,970 --> 00:04:49,200
So my head is going to have in the name of the type of string.

58
00:04:49,420 --> 00:04:59,750
And if you have an input call of the type you like color input Max here which is of the type Integer

59
00:05:00,130 --> 00:05:05,670
I would have been input this is not this which is of the type V.

60
00:05:06,320 --> 00:05:17,180
And then of course if that name becomes input's name so that in itself that color becomes him color

61
00:05:17,940 --> 00:05:19,570
self.

62
00:05:19,790 --> 00:05:22,170
Mike skeer becomes impolite.

63
00:05:22,180 --> 00:05:29,170
Skeer the self-taught status becomes input to the stocks.

64
00:05:29,840 --> 00:05:35,360
So once I have my Veikko class I'm going to go ahead and start two other classes.

65
00:05:35,360 --> 00:05:43,000
One of them is going to be called C down which is of the type B Kiang and it's going to be a subclass

66
00:05:43,000 --> 00:05:54,020
of my vehicle class and I have another one which is same thing of the class superclass vehicle.

67
00:05:54,100 --> 00:05:55,400
Nice cars.

68
00:05:57,180 --> 00:05:58,990
So that's another one.

69
00:05:59,100 --> 00:05:59,830
Perfect.

70
00:05:59,950 --> 00:06:02,870
And each of these will have their own things down.

71
00:06:02,880 --> 00:06:03,390
That's right.

72
00:06:03,390 --> 00:06:12,870
For instance for the see down when I say it has a value cost current year which is integer I'm currently

73
00:06:14,770 --> 00:06:16,420
now trying to think ahead.

74
00:06:16,450 --> 00:06:23,190
I know that in a few stages from now I have to make my storyboard and I have to populated the information

75
00:06:23,620 --> 00:06:28,350
and I'm thinking it would really help if I could put some dummy values in there.

76
00:06:28,480 --> 00:06:33,360
So the moment we begin the phrase there is actually something there that we can see.

77
00:06:33,550 --> 00:06:39,710
So to do that I'm going to go ahead and say I have a new class or a new suit file essentially.

78
00:06:39,880 --> 00:06:51,380
And when I call this one dummys and my dummys has a class called class dummies.

79
00:06:52,450 --> 00:06:54,300
I don't need a super class.

80
00:06:54,610 --> 00:07:02,110
And inside it I have a few things one of them is my dummys array something I say a static Grauer are

81
00:07:02,230 --> 00:07:11,580
dummies array which is going to be an array of vehicles and that's the thing that I need.

82
00:07:12,010 --> 00:07:20,950
And very important thing is I'm going with a class function called populate array and that class function

83
00:07:20,950 --> 00:07:23,940
is going to essentially populate this one.

84
00:07:23,950 --> 00:07:29,980
Now the reason that I made this one Istar thing is that because I want it to be accessible by other

85
00:07:30,050 --> 00:07:38,290
classes right out there need to essentially instantiate dummies was the same thing with the class function.

86
00:07:38,290 --> 00:07:40,350
I don't want to instantiate the dummies.

87
00:07:40,390 --> 00:07:43,840
I want to just use it every time that I need to.

88
00:07:43,930 --> 00:07:50,100
So populating this array is just a lot of legwork and I'm going to try to do it as fast as I can so

89
00:07:50,110 --> 00:07:52,200
we're going to spend a lot of time on this.

90
00:07:52,360 --> 00:07:59,990
So I have this one and then I have the let's let's call it the V the one which is going to be let's

91
00:08:00,060 --> 00:08:09,090
say a C done all of these values because I haven't yet programmed that it needs a specific to see that.

92
00:08:09,100 --> 00:08:11,510
It doesn't auto complete it for me.

93
00:08:11,680 --> 00:08:19,330
So here's a trick I could use I would say I'll use the in it from it and then change that to see that

94
00:08:19,420 --> 00:08:22,860
because I know they're exactly of the same nature.

95
00:08:23,080 --> 00:08:28,050
So I'm going to say my name is let's say who wrote the law.

96
00:08:28,460 --> 00:08:32,650
I only see I can't think of the color is you.

97
00:08:32,640 --> 00:08:35,230
I color dot it's red.

98
00:08:35,300 --> 00:08:37,560
Now I don't have access to you by color.

99
00:08:37,580 --> 00:08:43,890
So I have to import the you I checked and then I'm going to say maximum years or four out of four.

100
00:08:43,980 --> 00:08:47,720
And the regular state is out for instance.

101
00:08:47,740 --> 00:08:51,700
So that's one less capitis a few times.

102
00:08:52,530 --> 00:08:55,340
And this is going to be very cold too.

103
00:08:55,480 --> 00:08:59,810
When I say this is a fourth This is five.

104
00:08:59,860 --> 00:09:01,440
This is blue.

105
00:09:01,510 --> 00:09:03,630
This is available.

106
00:09:03,940 --> 00:09:10,070
I'm going to duplicate it again and this time and say it's going to be a fiat.

107
00:09:10,120 --> 00:09:20,070
If there is such a thing you know maybe five again and this time it is available and it's going to be

108
00:09:20,450 --> 00:09:21,150
free.

109
00:09:21,280 --> 00:09:24,740
One more time I think dove would do for us.

110
00:09:25,540 --> 00:09:30,740
And this time I actually am going to say it's not a see that and this thing is actually a truck.

111
00:09:30,850 --> 00:09:44,400
So this will be a truck of a dodge and it will be say on the trail of a car for a truck with a stick

112
00:09:44,720 --> 00:09:45,730
and it's a trailer.

113
00:09:45,910 --> 00:09:50,950
So I've got four vehicles and all four of them they have to go to these dummies.

114
00:09:50,950 --> 00:09:57,130
Of course this is something that you know you only do it when you are doing your testing and stuff.

115
00:09:57,120 --> 00:10:02,920
Otherwise it doesn't really happen that you have to manually add of this stuff to your arrays or members

116
00:10:02,920 --> 00:10:09,730
to your arrays because you wait for them to be dynamically either from either a backend or way different

117
00:10:09,730 --> 00:10:12,100
users from different parts of the network.

118
00:10:12,280 --> 00:10:17,280
But since you don't have that right now we have to essentially do it manually.

119
00:10:17,290 --> 00:10:21,250
So now I have some dummies that they can be populated.

120
00:10:21,280 --> 00:10:28,690
If somebody calls dummies that populate every now let's jump into our view control and started using

121
00:10:28,690 --> 00:10:29,620
those.

122
00:10:29,620 --> 00:10:37,170
The first thing I'm going to do is go to my view controller and say dummies that populate it.

123
00:10:37,360 --> 00:10:45,220
So I know by now this while you dummies that are dummies array has already gotten the values in it which

124
00:10:45,280 --> 00:10:46,690
I'm not going to use it like this.

125
00:10:46,690 --> 00:10:50,930
You have to use it to populate our text you know.

126
00:10:50,930 --> 00:10:52,850
To do that let's go to a story.

127
00:10:53,010 --> 00:11:00,790
And you know finish this fourth of my storyboard is going to have a fixed view which is the larger piece

128
00:11:00,790 --> 00:11:02,210
in here.

129
00:11:02,950 --> 00:11:05,640
I'm going to not like that.

130
00:11:05,680 --> 00:11:12,980
And I say let's place at the bar that I'm when I have a segmented control on the top.

131
00:11:13,490 --> 00:11:25,260
Are about here and the other one and the other and this one is going to be between sit down and talk

132
00:11:27,260 --> 00:11:36,660
boxes and sit downs and none of them is neither of them is going to be selected or at the beginning.

133
00:11:36,700 --> 00:11:39,550
This one however is going to have three members.

134
00:11:39,580 --> 00:11:43,880
Those three members are going to be available.

135
00:11:44,210 --> 00:11:52,230
A The second one is and is not currently selected and the next one is going to be out.

136
00:11:52,510 --> 00:11:56,020
And the third one is going to be repairers.

137
00:11:56,030 --> 00:12:00,510
So exactly the same names as we have in our you know.

138
00:12:01,030 --> 00:12:03,110
So we got that part taken care of.

139
00:12:03,220 --> 00:12:08,830
Now the next thing or essentially the last thing in here is I'm going to have to connect them to some

140
00:12:08,830 --> 00:12:12,190
sort of outlet in my view controller.

141
00:12:12,340 --> 00:12:15,420
I'm going to go to Assistant Editor in here.

142
00:12:15,490 --> 00:12:25,120
I'm going to say this one is going to be a status action because that's where you decide what kind do

143
00:12:25,120 --> 00:12:26,080
you want to show.

144
00:12:26,240 --> 00:12:28,960
But they're available out or repairs.

145
00:12:29,320 --> 00:12:33,280
And then this one is going to be that type action.

146
00:12:33,280 --> 00:12:37,610
So that's the type of action because it tells us the type of the car.

147
00:12:38,200 --> 00:12:44,840
And this one last one here is my text to you or raise text.

148
00:12:45,370 --> 00:12:49,260
I know they also have a button down there which I should have made it.

149
00:12:49,260 --> 00:12:55,340
That takes us to I think you get someone to do that right away as well.

150
00:12:55,360 --> 00:13:08,120
So that one in here essentially says you or I know this one has a different background.

151
00:13:08,500 --> 00:13:18,170
And this one is has an action saying add in you go to the new code to you.

152
00:13:19,090 --> 00:13:23,600
And that's about that I don't like.

153
00:13:23,890 --> 00:13:30,430
So now we got all of our actions on all of our outlets in our view control over all of this I'm trying

154
00:13:30,430 --> 00:13:34,460
to split them up simply because I know you know how to do them.

155
00:13:34,480 --> 00:13:39,820
So the first thing I want to do is this I want to make sure that one of them actually does something

156
00:13:39,820 --> 00:13:44,480
very simple like listing all of the values in the dummies that are.

157
00:13:44,530 --> 00:13:49,080
So let's do that first to do either of those you have to find out which.

158
00:13:49,120 --> 00:13:52,990
But then undi is segmented control.

159
00:13:53,010 --> 00:13:54,230
We have clicked on.

160
00:13:54,280 --> 00:14:06,080
So I'm going to go in here and say I have a let's call it index which is my Sandesh as you or I segmented

161
00:14:06,100 --> 00:14:13,720
control because I know it is a segmented control dot the selected segment index.

162
00:14:13,720 --> 00:14:19,970
So I find the index that they have clicked on and I need the exact same thing for my type action.

163
00:14:19,990 --> 00:14:24,770
Because here I have the type of segmented control.

164
00:14:25,060 --> 00:14:35,770
So I'm going here and say in the state of status let's switch that you switch the index in case it is

165
00:14:35,770 --> 00:14:36,770
zero.

166
00:14:36,940 --> 00:14:44,290
It means available simply because that is available Varney's out to is repairs.

167
00:14:44,440 --> 00:14:53,500
So that's that will do something about it in case it is a one that means out and we will do something

168
00:14:53,500 --> 00:14:54,060
about it.

169
00:14:54,080 --> 00:15:01,810
And in case it is true that means repairs and we will do something about it in the default mode just

170
00:15:01,810 --> 00:15:10,420
a break for me to be able to you know simplify my life and I actually copy this bit and pasted in here

171
00:15:10,420 --> 00:15:16,770
as well in the type of action because I have cases zero on one.

172
00:15:17,380 --> 00:15:24,670
So zero would be for sitdowns and one would be four tracks and not just go ahead and see what you want

173
00:15:24,670 --> 00:15:27,550
to do and what you want to do is this.

174
00:15:27,580 --> 00:15:34,750
If the first the first by the end of the segment that control if you want to go ahead and get the array

175
00:15:34,750 --> 00:15:41,650
from the dummies which is called the dummys array and you want to filter that out so only the ones that

176
00:15:41,650 --> 00:15:44,380
are available are shown if you press 1.

177
00:15:44,380 --> 00:15:48,500
Only the ones that are out on the press pass only the ones that are repete.

178
00:15:48,730 --> 00:15:54,120
So if you want to do that you have to put them inside an array themselves.

179
00:15:54,130 --> 00:16:02,800
So here's what I'm going to do say I have a very up here let's call it the viable current array which

180
00:16:02,800 --> 00:16:06,550
is an array of vehicles.

181
00:16:07,600 --> 00:16:10,170
Right the code to press this status.

182
00:16:10,210 --> 00:16:18,570
I'm going to go ahead and say My current array becomes a brand new one essentially I initialize it.

183
00:16:19,480 --> 00:16:21,860
So that part is taking care of.

184
00:16:21,940 --> 00:16:31,320
And then when I'm switching the index for the available ones I'm going to say for any color in dummys

185
00:16:31,470 --> 00:16:32,690
array.

186
00:16:35,430 --> 00:16:49,640
Effect way cool or any Ricca DOD status is a very status that is available if that is the case.

187
00:16:49,700 --> 00:16:56,410
Then add them to my current array then current array dot append.

188
00:16:56,600 --> 00:16:59,300
What would I want to add and any week.

189
00:17:00,080 --> 00:17:08,120
So that's about that by now we managed to have all of four elements in our dummys array filtered into

190
00:17:08,120 --> 00:17:11,960
the ones that are available and they're all in the current array.

191
00:17:11,960 --> 00:17:18,030
Same thing happens for a case 1 and same thing happens for K-Stew only going to copy everything.

192
00:17:18,050 --> 00:17:26,710
I'm going to sit in here say for anyone in there if they are out then add it to the current array for

193
00:17:26,720 --> 00:17:27,490
the last one.

194
00:17:27,530 --> 00:17:32,290
If they are other repairs add them to the current theory.

195
00:17:32,300 --> 00:17:40,040
So by the end of this switch which every case we have chosen our current array is now properly populated

196
00:17:40,040 --> 00:17:43,220
with the correct objects in it.

197
00:17:43,220 --> 00:17:49,700
So we have to do a very similar thing for when we tap the type action as well in here.

198
00:17:49,700 --> 00:17:52,100
We should check the Vache status.

199
00:17:52,130 --> 00:17:55,420
We have to check what kind of vehicle it is.

200
00:17:55,580 --> 00:17:57,790
So I'm actually going to copy everything in here.

201
00:17:57,950 --> 00:18:06,920
Say right at the beginning when we press the type action again do the same thing say initialize current

202
00:18:07,010 --> 00:18:14,820
array as a new era just like what we did here and then say the same thing exactly.

203
00:18:14,840 --> 00:18:21,800
So I'm copying Sir's a bit faster for any vehicle in there if the if statement is a little bit different.

204
00:18:22,080 --> 00:18:24,720
If this.

205
00:18:25,020 --> 00:18:34,420
Is it see sedan see Don is any We as see done.

206
00:18:34,430 --> 00:18:43,480
So if any cable is a down if that's the case then the array append does see that.

207
00:18:43,880 --> 00:18:50,960
So like that we managed to know for anyone in the dummys array if their vehicle is of the type sedan

208
00:18:51,320 --> 00:18:53,100
then added to the current array.

209
00:18:53,330 --> 00:18:59,030
I'm going to copy that in my father's case and the only thing that is going to be different is if it

210
00:18:59,030 --> 00:19:01,910
is as truck of course the naming.

211
00:19:01,910 --> 00:19:06,800
You could change it as this truck.

212
00:19:06,900 --> 00:19:15,350
So now I have these two functions that they each do something for us in terms of filtering my content.

213
00:19:15,380 --> 00:19:21,260
Now my code is becoming quite crowded and I also don't like you know the formatting that is in here.

214
00:19:21,410 --> 00:19:26,870
So what I'm going to do is I'm going to put either either of these two in a separate extension so when

215
00:19:26,870 --> 00:19:36,040
I go in here and say command and swift file and this is going to be my view controller plus type of

216
00:19:36,100 --> 00:19:37,320
action.

217
00:19:38,390 --> 00:19:40,750
And in this font is very simple.

218
00:19:40,770 --> 00:19:47,890
All I'm going to do is I'm going to say extension view controller and by extension view controller I'm

219
00:19:47,890 --> 00:19:55,140
going to go ahead and cut this whole plot say this entire part goes to type action.

220
00:19:55,280 --> 00:19:55,840
Perfect.

221
00:19:55,860 --> 00:20:01,130
And now I can formatted the way I like it which is very important for me.

222
00:20:01,190 --> 00:20:07,510
So like dogs I like him to be this way that's easier for me to read.

223
00:20:07,760 --> 00:20:12,110
And don't worry about that one error that you're seeing up there the error is simply saying I don't

224
00:20:12,110 --> 00:20:17,320
know what's a segment that control because in the extension I have to import the.

225
00:20:17,330 --> 00:20:18,580
You like it.

226
00:20:18,750 --> 00:20:22,930
But other than that everything is working the way we wanted it.

227
00:20:22,940 --> 00:20:24,940
So that is all type action.

228
00:20:24,950 --> 00:20:30,400
I'm going to go ahead and carp it is again say swift find this.

229
00:20:30,530 --> 00:20:39,410
I'm going to call it the status action so in my satisfaction once again I'm going to do the same thing.

230
00:20:39,520 --> 00:20:46,530
I know I have to import the kids and I know it is an extension of you controller.

231
00:20:46,990 --> 00:20:53,230
And then from my view controller I'm going to go ahead and say stop the section let's cut it and put

232
00:20:53,230 --> 00:20:56,500
it there and then that's about that.

233
00:20:56,510 --> 00:20:59,010
I can reformat it the way I want.

234
00:20:59,050 --> 00:21:01,780
You could do whichever you are used to.

235
00:21:01,960 --> 00:21:08,330
Or if you're just washing it just bear with me that you know because here's how I like it to be.

236
00:21:08,380 --> 00:21:16,530
So now when we press those buttons we have managed to successfully essentially filter our array to the

237
00:21:16,540 --> 00:21:20,500
ones that we want and place them in the current array.

238
00:21:20,500 --> 00:21:28,470
What we haven't done is some sort of a Mackell ism that goes ahead and shows it in our arrays text do

239
00:21:28,470 --> 00:21:29,010
you.

240
00:21:29,320 --> 00:21:34,480
I'm actually going to go put my rest takes you up there simply because it makes more sense.

241
00:21:34,490 --> 00:21:39,810
And now we have to write a new function that shows whatever you have in the current array.

242
00:21:39,820 --> 00:21:47,760
In the Rose text you call that function fine show a string.

243
00:21:48,090 --> 00:21:56,350
I'm going to have a title input title which is a string and how an input array which is going to be

244
00:21:56,440 --> 00:21:58,780
array of vehicles.

245
00:21:59,140 --> 00:22:01,410
So that's about that.

246
00:22:01,550 --> 00:22:02,970
And the body of the function.

247
00:22:02,980 --> 00:22:05,620
I already have it from the previous one that they did.

248
00:22:05,620 --> 00:22:11,280
So I'm actually only going to copy paste that so I don't have to waste your time going through it.

249
00:22:11,290 --> 00:22:13,930
It's a very simple you know text production.

250
00:22:13,930 --> 00:22:17,380
It says there is a value of a string that you want to show.

251
00:22:17,380 --> 00:22:21,880
It begins with whatever title that you have with that title.

252
00:22:21,910 --> 00:22:23,740
We are carrying to it.

253
00:22:23,770 --> 00:22:30,160
And then for any vehicle in the trade that we have we go through the next line with TARP and then we

254
00:22:30,160 --> 00:22:37,510
put the name of the current uppercase or a line down and we go to tabs and then we show the color of

255
00:22:37,510 --> 00:22:41,720
it and then be sure the Year of Faith and then we should start to solve it.

256
00:22:41,770 --> 00:22:43,940
Now a few things I have to change.

257
00:22:44,040 --> 00:22:46,600
I'm one of them is actually very important.

258
00:22:46,600 --> 00:22:49,010
The most important one is this one.

259
00:22:49,300 --> 00:22:56,260
How are we going to show the color of something because as you can imagine it colors such as this one

260
00:22:57,190 --> 00:22:59,500
your eye color that red.

261
00:22:59,590 --> 00:23:01,020
It's not text.

262
00:23:01,180 --> 00:23:05,440
It can't be red eyes or E as a string.

263
00:23:05,440 --> 00:23:12,040
So we have actually to write something that takes colors and converts them to names.

264
00:23:12,130 --> 00:23:18,160
So unfortunately there is no such a mechanism built into swift or excoriation I have to make my own

265
00:23:18,160 --> 00:23:19,050
version of it.

266
00:23:19,210 --> 00:23:25,770
So I'm going to go ahead and start a new file called swift and I'm going to call you white collar last

267
00:23:25,780 --> 00:23:26,740
name.

268
00:23:27,070 --> 00:23:29,670
So this is a new extension for you.

269
00:23:29,720 --> 00:23:34,300
Kardash so in yeah I'm going to say an extension for you.

270
00:23:34,300 --> 00:23:41,990
I call parlor and I think they have to import you UI kit.

271
00:23:42,640 --> 00:23:50,380
OK so now I'm here I'm going to go ahead and say let's do this say variable name that is this string

272
00:23:50,910 --> 00:23:56,290
and that this thing I'm going to say switch to self.

273
00:23:56,920 --> 00:24:03,800
And then I'm switching self I'm going to say in case it was your eye color dots.

274
00:24:04,480 --> 00:24:10,050
Then read the text.

275
00:24:10,720 --> 00:24:17,620
So for every color I'm going to go ahead and write a value which is a text value that we can return.

276
00:24:17,620 --> 00:24:19,410
So I'm going to copy this a few times.

277
00:24:19,420 --> 00:24:23,960
I'm not going to do every case simply because you know we don't have much time.

278
00:24:23,970 --> 00:24:37,240
But for red blue green yellow sign on either end or the dark gray and light gray maybe for all of these

279
00:24:37,240 --> 00:24:38,230
will take care of it.

280
00:24:38,230 --> 00:24:44,430
So four lights created right Gary for the directory and directory for sound and so on.

281
00:24:44,620 --> 00:24:46,090
So on and so forth.

282
00:24:46,090 --> 00:24:52,840
So I make sure that for every value that I have I get some text value as a result.

283
00:24:52,840 --> 00:24:53,730
So red.

284
00:24:53,800 --> 00:25:00,680
And in case of default our return which obviously doesn't really happen.

285
00:25:00,700 --> 00:25:07,270
So what this extension does for us is that it offers us a way to know whatever the color is.

286
00:25:07,270 --> 00:25:09,450
What is the fixed value of it.

287
00:25:09,520 --> 00:25:11,230
Now I could actually use this.

288
00:25:11,320 --> 00:25:19,210
I could go to my of your controller and then I could say each week a color and then get the name of

289
00:25:19,210 --> 00:25:19,740
it.

290
00:25:19,750 --> 00:25:21,800
So I think that error will go over.

291
00:25:21,820 --> 00:25:23,160
Yes it did cause it.

292
00:25:23,470 --> 00:25:27,700
So now we have a string that gets shown in here.

293
00:25:27,740 --> 00:25:30,890
And let's put this in a separate extension as well.

294
00:25:30,940 --> 00:25:31,990
I'm going to cut that.

295
00:25:31,980 --> 00:25:45,350
Say this is the view controller Plus show a string and this one would be in for you.

296
00:25:45,720 --> 00:25:50,340
It would be an extension to you control.

297
00:25:50,530 --> 00:25:52,720
And I have have this one function.

298
00:25:53,170 --> 00:25:55,890
And now we can actually go ahead and use this one.

299
00:25:55,930 --> 00:25:57,170
When are we going to use it.

300
00:25:57,170 --> 00:26:03,340
We're going to the end of the year start this action saying once you did this switch and we were happy

301
00:26:03,340 --> 00:26:06,600
with its results say switch a string.

302
00:26:06,870 --> 00:26:11,780
And yet for the input array I'm going to say current array.

303
00:26:12,820 --> 00:26:18,250
And for the title the title depends on the one of these cases.

304
00:26:18,340 --> 00:26:25,120
So you could either introduce a string that each time gets one of these values or you could have run

305
00:26:25,120 --> 00:26:28,890
this function inside the body of all of these cases.

306
00:26:28,970 --> 00:26:34,120
So either order is going to be essentially the same so I'm going to go ahead and actually opt for the

307
00:26:34,120 --> 00:26:35,800
second solution.

308
00:26:35,800 --> 00:26:38,380
I'm going to say in case of zero.

309
00:26:38,410 --> 00:26:42,460
Go ahead and say IMPA title available.

310
00:26:43,030 --> 00:26:46,140
And those are array in case of one.

311
00:26:46,150 --> 00:26:57,510
Go ahead and say in the title is out and the aere in case of repairs going here say repairs and that

312
00:26:57,570 --> 00:26:58,210
that.

313
00:26:58,540 --> 00:27:05,020
And you have to do the exact same thing for our type auction type auction I'm going to go in here and

314
00:27:05,020 --> 00:27:14,970
say well when you're doing the you find the see dollars go ahead and say idea and title is sitdowns

315
00:27:15,200 --> 00:27:19,830
on at the end of here implied is trucks

316
00:27:22,180 --> 00:27:25,600
OK long you've tried so far.

317
00:27:25,600 --> 00:27:30,520
So let's run the application at least one see if you haven't done anything terribly wrong.

318
00:27:30,640 --> 00:27:37,080
And if you have done so much coding without anything happening and you have to see how you're doing

319
00:27:37,160 --> 00:27:44,300
and if I press available we see the available cards out out cause repairs around there is no one sit

320
00:27:44,340 --> 00:27:44,890
downs.

321
00:27:44,890 --> 00:27:47,540
Are these three trucks of those.

322
00:27:47,650 --> 00:27:51,080
So maybe it helps if you put one of them at repair.

323
00:27:51,100 --> 00:27:53,620
So I'm going to go to donees.

324
00:27:53,970 --> 00:27:58,910
I'm the dummy and when I say this fun is the repairs.

325
00:27:58,960 --> 00:28:05,660
Now of course we haven't really planned for anything that says from the available vans.

326
00:28:05,680 --> 00:28:07,310
Show me the sedans.

327
00:28:07,480 --> 00:28:13,510
Right now each of these two segmented controls they work essentially independently and I leave that

328
00:28:13,510 --> 00:28:16,370
to you guys to figure out how you want to do that.

329
00:28:16,540 --> 00:28:22,680
But you know in a real functioning application especially with the design that I have that on the top

330
00:28:22,680 --> 00:28:27,240
you have the available ones on the top you have the status ones.

331
00:28:27,430 --> 00:28:32,510
And then we have the type ones you want to make sure that these two correlate to each other.

332
00:28:32,500 --> 00:28:39,540
So pressing out on anthrax should show the trucks that are currently out but I leave that to you guys.

333
00:28:39,790 --> 00:28:45,190
For me however let's go ahead in here and say we have everything up until now.

334
00:28:45,190 --> 00:28:54,220
The thing that we don't have is going to be adding a new one and then from there on adding one more

335
00:28:54,730 --> 00:28:55,730
thing in here.

336
00:28:55,900 --> 00:29:06,370
So let's go ahead into my story about and in here I'm going to go ahead and add a new controller.

337
00:29:06,540 --> 00:29:09,190
So this is my new controller.

338
00:29:09,570 --> 00:29:14,880
So once again in here I'm actually going to cheat and I'm not going to remake everything simply because

339
00:29:14,880 --> 00:29:22,650
I don't want to make this video very long so I copied and pasted from my previous article they had done.

340
00:29:22,650 --> 00:29:25,200
And these are all the things that we need in here.

341
00:29:25,210 --> 00:29:31,400
We need a little of button up there I need a type I segmented control.

342
00:29:31,420 --> 00:29:38,870
Then we need a text field in a color or a slider or we need a color indicator.

343
00:29:38,970 --> 00:29:44,080
We have a two step or one step at essentially plus minus.

344
00:29:44,100 --> 00:29:49,030
And we have a status that you know at the end if you can choose what is the status of that card.

345
00:29:49,030 --> 00:29:54,120
I'm adding to the network or to mine to my data essentially.

346
00:29:54,120 --> 00:29:58,990
And then I want to go ahead and say let's have a Segway.

347
00:29:59,150 --> 00:30:02,420
And that's like it is from here to there.

348
00:30:02,490 --> 00:30:10,280
Let's call it 2 here to say.

349
00:30:10,350 --> 00:30:20,780
I am going to copy that name to my view controller and say in the code to add new self performs segue

350
00:30:21,450 --> 00:30:27,470
with identifier that one with no senders right now.

351
00:30:27,980 --> 00:30:30,150
And live it on the application once again.

352
00:30:30,150 --> 00:30:38,130
We should be able to navigate successfully into our new controller even though there's really nothing

353
00:30:38,130 --> 00:30:39,420
happening in there.

354
00:30:39,540 --> 00:30:46,380
So if we can go in here and now we have to worry about what we should do in this new controller.

355
00:30:46,530 --> 00:30:52,410
So for this next thing I'm going to build the pieces for my ADD the view controller which is in here

356
00:30:53,070 --> 00:30:58,380
for this one I'm actually going to pause the video and do it because it's such a repetitious thing and

357
00:30:58,380 --> 00:30:59,680
I don't want to waste your time.

358
00:30:59,680 --> 00:31:01,880
So bear with me for a second.

359
00:31:02,250 --> 00:31:06,000
So when the video was on pause I did the following things.

360
00:31:06,000 --> 00:31:13,280
I added a new class called add the View Controller and that's obviously a subclass of view controller.

361
00:31:13,290 --> 00:31:21,120
I applied that to my view controller outlet in my storyboard and I connect that these different outlets.

362
00:31:21,130 --> 00:31:29,010
They're a text field a label for the girls a label for the warning a slider for the color and a box

363
00:31:29,010 --> 00:31:30,720
that shows the colors.

364
00:31:30,810 --> 00:31:37,560
And these are here so this is my textfield This is my warning label that has that little box that I

365
00:31:37,560 --> 00:31:39,240
can see the different colors on it.

366
00:31:39,240 --> 00:31:40,580
Maybe I make it.

367
00:31:41,050 --> 00:31:43,390
I don't know a different color by default.

368
00:31:43,410 --> 00:31:45,120
This is my little label.

369
00:31:45,130 --> 00:31:46,820
I see the different years.

370
00:31:46,910 --> 00:31:48,450
And that's obviously my ADD.

371
00:31:48,500 --> 00:31:56,140
And these two are now connected to two functions via the value changed event which one of them is change

372
00:31:56,140 --> 00:31:56,880
of type.

373
00:31:56,880 --> 00:31:58,730
The other one is change of status.

374
00:31:58,740 --> 00:32:02,940
Of course I have the action that are in here.

375
00:32:03,060 --> 00:32:09,080
I have a value changed color change that is the one that applies to the slider.

376
00:32:09,120 --> 00:32:17,670
I have a step her value change that is for when I changed gears I've ever made a mistake in here I'm

377
00:32:17,670 --> 00:32:25,510
going to fix that is not a touch up inside change color of a number of years is actually value changed.

378
00:32:25,860 --> 00:32:29,280
So those are the things I have in my ad the view controller.

379
00:32:29,280 --> 00:32:32,150
Let's go ahead and get started with them.

380
00:32:32,160 --> 00:32:37,860
So the first thing I want to be able to do is I want to be able to change the color by the slider so

381
00:32:37,860 --> 00:32:42,090
to do that I need an array of all the colors that are available to me.

382
00:32:42,300 --> 00:32:47,710
And then to go ahead and say I have something called the valuable collar's array.

383
00:32:47,850 --> 00:32:50,950
And that's going to be an array of you.

384
00:32:50,960 --> 00:32:57,850
I color and I'm going to have to populate that somebody somewhere right.

385
00:32:57,880 --> 00:33:02,300
A function populates collar's array.

386
00:33:02,720 --> 00:33:04,420
And that would do that.

387
00:33:04,470 --> 00:33:10,680
It really helps me for the reasons that you will see really soon enough Does this area in here and these

388
00:33:10,680 --> 00:33:12,490
callers are in the same order.

389
00:33:12,660 --> 00:33:14,190
So I'm going to copy these.

390
00:33:14,550 --> 00:33:23,100
When I say copy I'm going to go in there and say Claras array becomes an array of all of these guys.

391
00:33:23,160 --> 00:33:29,460
Of course not the way they are I have to get rid of all the cases and I'm going to do that and I have

392
00:33:29,460 --> 00:33:30,960
to get rid of all of these.

393
00:33:30,960 --> 00:33:34,840
So you might call a blind curate all the way to light gray.

394
00:33:35,160 --> 00:33:40,020
So I paused the video and I populated my colors array the next thing I'm going to do is I'm going to

395
00:33:40,020 --> 00:33:50,100
say my color a slider so color the slider that minimum value becomes a zero color a slider the maximum

396
00:33:50,100 --> 00:33:56,860
value becomes my collieries array doth count minus 1.

397
00:33:57,060 --> 00:34:02,310
So essentially becomes where there is the maximum number there minus 1 which is the range.

398
00:34:02,310 --> 00:34:05,490
We can go through as if you are using the array.

399
00:34:05,550 --> 00:34:11,680
So doubts about that was giving me an error saying that this value is an integer word here.

400
00:34:11,700 --> 00:34:19,200
You need to have a flow with someone to say Give me a lot of that value get integer converted into a

401
00:34:19,200 --> 00:34:20,010
float.

402
00:34:20,010 --> 00:34:24,810
So now if I go through a wide Slider I should be able to see different colors.

403
00:34:24,810 --> 00:34:27,340
Let's go ahead and implement that.

404
00:34:27,390 --> 00:34:36,460
So to do that I have to essentially say color box dark background color becomes colors array and someone

405
00:34:36,510 --> 00:34:38,550
from crullers array should be there.

406
00:34:38,730 --> 00:34:41,650
That one depends on where my slider is.

407
00:34:41,670 --> 00:34:45,880
So let's go ahead and say let's index becomes.

408
00:34:46,080 --> 00:34:48,570
I have to get the value of my a slider.

409
00:34:48,570 --> 00:34:54,420
I'm going to say my curve is neither to value but as we know this is a float value.

410
00:34:54,420 --> 00:35:01,050
So if I can convert it to an integer and even if I said this is an integer that value might actually

411
00:35:01,050 --> 00:35:06,780
reach the upper bound and because of that I'm actually going to have to manually convert it into an

412
00:35:06,780 --> 00:35:07,560
integer.

413
00:35:07,790 --> 00:35:14,730
And as we saw it sometimes earlier I have to around it to know that the value that I'm getting is exactly

414
00:35:14,730 --> 00:35:16,110
the correct value.

415
00:35:16,140 --> 00:35:22,860
So when I'm rounding I get any value between 0 2.5 to become 0.

416
00:35:22,860 --> 00:35:25,470
Anything above point 5 to become one.

417
00:35:25,560 --> 00:35:31,680
So on and so forth I get all the boundaries that I need and I'm going to say colored box by gun color

418
00:35:31,680 --> 00:35:35,040
becomes color as array index.

419
00:35:35,070 --> 00:35:38,090
This index Let's see if that part is working.

420
00:35:38,190 --> 00:35:39,630
We're on the application

421
00:35:43,360 --> 00:35:48,410
and if I go here and I say that I had crushes.

422
00:35:48,810 --> 00:35:55,170
The reason it crashed is something I completely forgot and that is we never actually use this array

423
00:35:55,440 --> 00:35:56,630
or this function.

424
00:35:56,790 --> 00:36:02,040
So I'm going to go to my view of the Lord and say here populate the array as well so the array is not

425
00:36:02,130 --> 00:36:02,910
empty.

426
00:36:03,150 --> 00:36:09,030
So I'm going to run this again and this time and it loads up we shouldn't have that issue anymore.

427
00:36:10,890 --> 00:36:15,350
So now I can go through all the columns that I have in my array.

428
00:36:15,360 --> 00:36:15,810
Perfect.

429
00:36:15,810 --> 00:36:17,910
So that part is taken care of.

430
00:36:17,910 --> 00:36:24,180
Now let's go ahead and on the ISTEP her value for here for the changing of the number of the gifts that

431
00:36:24,180 --> 00:36:34,110
should be really easy here in here and I'm going to say give me the years label dot text and that becomes.

432
00:36:34,170 --> 00:36:38,140
And here's the value that they want to put in the string of the text.

433
00:36:38,220 --> 00:36:41,440
I want to have a interpretation of that.

434
00:36:41,610 --> 00:36:49,120
And it's going to be a bit of a long one but it's going to be send there as you point a step or not.

435
00:36:49,200 --> 00:36:51,360
That's one I'm going to make it.

436
00:36:51,510 --> 00:36:53,340
Give me the value.

437
00:36:53,490 --> 00:36:55,230
Now the value is a double.

438
00:36:55,230 --> 00:37:00,180
So I'm going to say give me the integer of that value.

439
00:37:00,510 --> 00:37:02,510
So it's a very long process.

440
00:37:02,500 --> 00:37:09,990
But it says give me the integer part of the send as is the per value interpreted.

441
00:37:10,080 --> 00:37:12,280
All of that into a string.

442
00:37:12,450 --> 00:37:13,230
So let's right now

443
00:37:16,850 --> 00:37:22,080
and here I can change the values.

444
00:37:22,750 --> 00:37:28,810
So the next two things are changing the starters and also changing the type and both of these they kind

445
00:37:28,810 --> 00:37:35,920
of need to be stored somewhere simply because as we change these guys we are not going to do anything

446
00:37:35,920 --> 00:37:38,760
with them unless you press the add the button.

447
00:37:38,830 --> 00:37:46,270
So we have to store these two values somewhere that we know our user has chosen to be a sideline or

448
00:37:46,270 --> 00:37:47,570
an available one.

449
00:37:47,620 --> 00:37:51,570
And then when we had the odds but then they get to reflect somewhere.

450
00:37:51,730 --> 00:37:57,370
So because of that I'm going to go up here and say Give me your valuables.

451
00:37:57,370 --> 00:38:01,990
One of them is going to be valuable and select that type.

452
00:38:01,990 --> 00:38:04,130
And that's going to be a string.

453
00:38:04,420 --> 00:38:08,820
And the other one is going to be valuable new movie called dictionary.

454
00:38:08,830 --> 00:38:12,640
And that's going to be a dictionary of a string.

455
00:38:12,760 --> 00:38:14,060
And in.

456
00:38:14,890 --> 00:38:20,160
And they're both optional but explicitly aren't optional.

457
00:38:20,410 --> 00:38:25,870
So here's what I'm going to do in my change of status in my change of status.

458
00:38:25,870 --> 00:38:29,990
I'm going to say let's find what is this not as we chose.

459
00:38:30,090 --> 00:38:40,180
Going to say let our select that index to be let's get send there as your eyes segmented control and

460
00:38:40,180 --> 00:38:43,200
then let's get the selected segment index.

461
00:38:43,390 --> 00:38:51,420
So from this selected segment index which is this one from this status we're going to get zero for available

462
00:38:51,430 --> 00:38:53,850
one for out and two for repairs.

463
00:38:53,860 --> 00:39:00,820
So we don't got Why add the view controller and say based on data based on whatever is the status they

464
00:39:00,820 --> 00:39:01,830
have selected.

465
00:39:02,080 --> 00:39:08,590
Now here is the part that we have to go back to our income and make some changes because I could run

466
00:39:08,620 --> 00:39:12,890
if a statement say if selected index was zero set it today.

467
00:39:12,910 --> 00:39:14,900
If it was run say to the other one.

468
00:39:15,070 --> 00:39:19,270
But if we choose to use the roll values things are going to be a lot easier.

469
00:39:19,650 --> 00:39:29,200
So to do that I'm going to put my arms I'm going say my available is zero and my out is 1 and these

470
00:39:29,200 --> 00:39:30,360
other are all values.

471
00:39:30,400 --> 00:39:34,970
And then the moment they do this is going to give me an error saying so you have to type your income

472
00:39:35,260 --> 00:39:38,290
and I'm going to say fine my arm is in.

473
00:39:38,320 --> 00:39:40,180
And while I did I'm going to make it.

474
00:39:40,190 --> 00:39:42,080
Chase i3 traceable as well.

475
00:39:42,280 --> 00:39:44,370
So I don't have to come back to it anymore.

476
00:39:44,380 --> 00:39:50,580
So now my arms they have names my cases they have names and they also have a role value.

477
00:39:50,740 --> 00:39:53,360
So now I could simply go back to mine.

478
00:39:53,450 --> 00:40:00,940
And if you can for one year I could say instead of running an if statement I could say we used the roll

479
00:40:00,940 --> 00:40:04,030
values to find out what we want to put in there.

480
00:40:04,040 --> 00:40:05,580
So I'm going to say no we can't.

481
00:40:05,580 --> 00:40:06,610
Dictionary.

482
00:40:06,960 --> 00:40:11,610
And I'm going to call this one the status keep the status G.

483
00:40:11,890 --> 00:40:18,030
That's going to be and value that they want to put it is this regular state.

484
00:40:18,260 --> 00:40:25,880
I'm going to get the roll value wrong value under all that you want to get it from this guy.

485
00:40:25,880 --> 00:40:28,780
Select that index.

486
00:40:28,900 --> 00:40:30,560
Now it's a little bit of fun.

487
00:40:30,570 --> 00:40:32,020
You know a challenge in here.

488
00:40:32,020 --> 00:40:41,400
One of them is that I'm entering a vague killer state twist throwing into my new Quaker dictionary my

489
00:40:41,580 --> 00:40:49,000
fecal dictionary does I accept any which makes it perfectly fine to enter values such as this one but

490
00:40:49,030 --> 00:40:54,730
the compiler cannot compile a value such as this number they have to do is I have to make sure that

491
00:40:55,030 --> 00:40:57,200
I interpret this as a string.

492
00:40:57,220 --> 00:41:00,450
So I'm going to say this is actually a string.

493
00:41:00,460 --> 00:41:01,860
I'm trying to produce.

494
00:41:01,990 --> 00:41:06,780
So get this converted into a string and place it in my status key.

495
00:41:06,940 --> 00:41:08,010
And now you're saying.

496
00:41:08,020 --> 00:41:11,680
Are you sure this value which is an optional one does exist.

497
00:41:11,690 --> 00:41:14,700
Then I'm going to say yes I know it's absolutely there.

498
00:41:15,220 --> 00:41:22,300
I just realized something and if you were super perceptive you probably saw it before I did and that

499
00:41:22,300 --> 00:41:25,860
is my new vehicle dictionary was never initialized.

500
00:41:26,080 --> 00:41:30,010
I did define its type or declare and.

501
00:41:30,110 --> 00:41:35,620
But they never initialized it so I can actually go ahead and say let's initialize it on the fly right

502
00:41:35,620 --> 00:41:37,020
at the very beginning.

503
00:41:37,170 --> 00:41:41,620
New medical dictionary is an initialized dictionary of a string.

504
00:41:41,620 --> 00:41:44,610
An array doesn't currently have any id..

505
00:41:44,630 --> 00:41:49,640
It's just an initialized but soon we're going to you know enter values into it.

506
00:41:49,960 --> 00:41:56,450
So so far I got to store my status somewhere in here.

507
00:41:56,470 --> 00:42:01,010
The next thing I want to do is I want to store my type or at least remember its number.

508
00:42:01,030 --> 00:42:06,140
So for that again I'm going to do this because again I have an.

509
00:42:06,220 --> 00:42:14,400
Selection index from a segmented control and then I'm going to say switch this value switch selector

510
00:42:14,520 --> 00:42:24,780
index and if case zero say select that type is going to be done simply because I know that zero is down.

511
00:42:24,780 --> 00:42:27,240
One is Iraq.

512
00:42:27,370 --> 00:42:36,030
I'm going to go ahead and say in case it was one selected time make Maajid truck.

513
00:42:36,190 --> 00:42:38,970
So I am storing that value.

514
00:42:38,980 --> 00:42:45,560
The change of the type in something called select that type as well I think case it was the just bricks

515
00:42:45,580 --> 00:42:47,180
don't do anything.

516
00:42:47,680 --> 00:42:53,790
So almost everything is ready except that they have missed out on a few things yet one of them is.

517
00:42:53,830 --> 00:43:01,870
So the record that the change of status in our in our dictionary we have recorded record number of years

518
00:43:01,930 --> 00:43:05,830
we haven't recorded the color we haven't recorded.

519
00:43:05,830 --> 00:43:09,040
Whatever is the value that we get in the text.

520
00:43:09,250 --> 00:43:13,960
So as you can imagine when we want to head out the we need to know the status we need to know the number

521
00:43:13,960 --> 00:43:16,890
of years color and the value of the text.

522
00:43:16,960 --> 00:43:22,610
And we need to know which one it is of these five is still three of them we haven't decoded anyway.

523
00:43:22,780 --> 00:43:27,670
So I'm going to go in here and say some of them are easier than the other ones so let's do the easy

524
00:43:27,670 --> 00:43:31,200
ones first the easiest right now is the number of the years.

525
00:43:31,240 --> 00:43:32,490
So then we change it.

526
00:43:32,500 --> 00:43:34,460
This is the value that we are storing.

527
00:43:34,510 --> 00:43:45,360
And I'm also going to say new way kill our dictionary and the value for let's call it here is she is

528
00:43:45,370 --> 00:43:51,040
going to be undervalues or they want to enter into it is whatever we find in there.

529
00:43:51,050 --> 00:43:53,740
So which is essentially the sky.

530
00:43:54,140 --> 00:44:02,380
So integer of that so that value I place it inside my Gere's key.

531
00:44:02,380 --> 00:44:07,300
So the moment the value changes on the number of the years that value we see it in there.

532
00:44:07,450 --> 00:44:13,490
And if you want we can actually use the use the combination of these two to show it on your years label

533
00:44:13,490 --> 00:44:16,240
as verb which is a better practice generally.

534
00:44:16,240 --> 00:44:18,480
So now there is a stored somewhere.

535
00:44:18,490 --> 00:44:20,140
I'm going to copy that.

536
00:44:20,230 --> 00:44:23,350
Say that is what I want you to show.

537
00:44:23,350 --> 00:44:26,030
So I don't do the same thing twice.

538
00:44:26,050 --> 00:44:33,970
I placed the value inside my dictionary then I get the value from the dictionary and wrap it and place

539
00:44:33,970 --> 00:44:35,600
it inside my label.

540
00:44:35,860 --> 00:44:40,620
So by now our dictionary has the year's key it has this Thatha ASCII.

541
00:44:40,660 --> 00:44:47,290
So these two are taken care off with essentially for these two four fold.

542
00:44:47,290 --> 00:44:50,490
Now the missing pieces are one of them is the color.

543
00:44:50,500 --> 00:44:52,710
The other one is the value of the text.

544
00:44:52,990 --> 00:44:56,640
Let's fix the text field first because it's an easier one.

545
00:44:56,740 --> 00:45:02,260
I'm going to go in here and say my textfield whatever I call it which I don't really remember.

546
00:45:02,260 --> 00:45:06,180
Next name takes VIDOT delegates to self.

547
00:45:06,290 --> 00:45:10,560
And I'm going to go ahead and say your view opens for you.

548
00:45:10,560 --> 00:45:11,100
All right.

549
00:45:11,100 --> 00:45:15,260
Textfield delegate it conforms to the textfield delegate.

550
00:45:15,550 --> 00:45:22,700
And since it does that I can use a function such as text fields should return.

551
00:45:23,020 --> 00:45:25,050
And if it does do that.

552
00:45:25,060 --> 00:45:26,190
Here's what I want to do.

553
00:45:26,200 --> 00:45:32,570
I want to say the new Charles dictionary value for the name.

554
00:45:32,680 --> 00:45:40,610
I want it to become text field dot text so whatever is in there put it inside the name key.

555
00:45:40,840 --> 00:45:45,370
And of course they text in Dot resign the first responder.

556
00:45:45,640 --> 00:45:54,430
So every time we had to enter on the text field we get rid of the keyboard and we all sort of what you

557
00:45:54,430 --> 00:45:57,060
call the a store the value of it.

558
00:45:57,100 --> 00:46:00,830
But there is an error because they forgot that this is a boolean function.

559
00:46:00,970 --> 00:46:04,700
I have to say return TRUE was at the end of it.

560
00:46:04,810 --> 00:46:07,430
So that part we took care of.

561
00:46:07,810 --> 00:46:16,180
The most difficult one perhaps is this one the changing of the color which gives us a color not trying

562
00:46:17,170 --> 00:46:22,520
to fix not what we need to do is we need to find that color and put Hughson name out of it.

563
00:46:22,570 --> 00:46:27,650
And that is something we have already done in your eye color name.

564
00:46:27,800 --> 00:46:35,230
So I can simply going here and say every time you do this you go ahead and say No raker dictionary value

565
00:46:35,230 --> 00:46:45,840
for color she becomes and the value needs to have is exactly the sky which is a color dot name.

566
00:46:46,060 --> 00:46:51,500
So I'm going to say get the name of that color and place it in here.

567
00:46:51,550 --> 00:46:59,590
So by now we have managed to get the color put in a dictionary get the name it in the dictionary which

568
00:46:59,590 --> 00:47:04,630
is in our text field here and get the gear within our dictionary.

569
00:47:04,630 --> 00:47:09,520
Get this that this is in our dictionary and find the type and put it in here.

570
00:47:09,520 --> 00:47:12,930
So finally we have to actually add all of those things.

571
00:47:13,030 --> 00:47:15,700
And before that we actually run a little test.

572
00:47:15,730 --> 00:47:23,080
So I'm going to say let's have another function call validate and what validate does is make sure that

573
00:47:23,170 --> 00:47:25,750
everything we want is already selected.

574
00:47:25,750 --> 00:47:30,330
If somebody is still there is going to tell us hey you have to do something.

575
00:47:30,460 --> 00:47:31,950
So that is very simple.

576
00:47:32,140 --> 00:47:36,570
We have to make sure that our dictionary has four members.

577
00:47:36,670 --> 00:47:38,310
So I'm going to write.

578
00:47:38,900 --> 00:47:51,920
If your vehicle dictionary dot all values dot values dot count is below 4.

579
00:47:52,210 --> 00:48:02,730
If it is not 4 yet and or month or select that type is near.

580
00:48:02,860 --> 00:48:09,070
It means we either haven't selected everything that we need or we haven't selected the type that we

581
00:48:09,070 --> 00:48:09,620
need.

582
00:48:09,730 --> 00:48:17,480
If either of these things happened do this say warning label that hidden becomes false.

583
00:48:17,490 --> 00:48:27,800
So we can actually see it now and the warning label dot text because all fields are mandatory.

584
00:48:27,940 --> 00:48:29,940
So that's about that.

585
00:48:30,130 --> 00:48:33,280
If that didn't happen then you can do something.

586
00:48:33,430 --> 00:48:37,460
Let's go ahead and really quickly use that before we actually use it.

587
00:48:37,630 --> 00:48:43,730
I'm going to say whenever I had the I'd rather do this say validate.

588
00:48:43,790 --> 00:48:47,230
All right let's make sure the validate returns a boolean.

589
00:48:47,260 --> 00:48:49,680
So if this was the case.

590
00:48:49,690 --> 00:48:56,690
Dude all of these things and return a false Indianness return true.

591
00:48:57,740 --> 00:49:06,200
Return through I'm going to do something else in there and else I'm going to say warning label hides

592
00:49:06,230 --> 00:49:06,730
again.

593
00:49:06,740 --> 00:49:10,460
So this thing I enjoy I've actually done something quickly.

594
00:49:10,580 --> 00:49:22,140
So in my action let's say if validate and the valley that if it is true let's say I get on this mess

595
00:49:22,760 --> 00:49:27,050
and I was a on.

596
00:49:28,010 --> 00:49:30,910
So I'm going to commence this temporal way.

597
00:49:30,920 --> 00:49:37,850
So here what we have is this we go and we try to validate whether our user has entered everything correctly.

598
00:49:37,850 --> 00:49:45,830
If they haven't we see a little warning if they have we get rid of the warning and we push to push back

599
00:49:45,830 --> 00:49:47,490
to our previous viewpoint.

600
00:49:47,750 --> 00:49:51,800
Let's go ahead and run this application so we're almost at the end of this development.

601
00:49:51,800 --> 00:49:55,430
So if I go to odds a new one say sit down and head out.

602
00:49:55,460 --> 00:49:57,830
It says All fields are mandatory.

603
00:49:57,890 --> 00:50:03,950
If I say the name is for I I that is still the same thing is going to happen put in place like all five

604
00:50:03,950 --> 00:50:06,650
of them had are that's going to disappear.

605
00:50:06,650 --> 00:50:09,000
It means everything has worked well.

606
00:50:09,020 --> 00:50:15,690
So now the final challenge is we know we now have a proper dictionary that has all the information I

607
00:50:15,700 --> 00:50:23,480
have has for green one and out and we have to send that dictionary to our type whether it is Saddam

608
00:50:23,600 --> 00:50:26,870
or the other one and make in you we can.

609
00:50:26,930 --> 00:50:28,820
So let's see how are we going to do that.

610
00:50:28,850 --> 00:50:35,540
So to do that we need to make sure that both are sit down and traunch they can actually initialize themselves

611
00:50:35,550 --> 00:50:37,310
using a dictionary.

612
00:50:37,340 --> 00:50:43,660
So in it using a dictionary to do that I'm going to say I have a convenience.

613
00:50:43,680 --> 00:50:48,750
It's not like that convenience in it.

614
00:50:49,100 --> 00:50:57,470
And that convenience in it has an input dictionary of the type dictionary of a string.

615
00:50:57,530 --> 00:50:58,890
And any.

616
00:50:59,070 --> 00:51:03,950
All right just like what you have done when they're studying convenience and it's I mean you know when

617
00:51:03,950 --> 00:51:11,630
I say God let go and let is going to be are all of the values that we have in there so we have a name

618
00:51:11,990 --> 00:51:17,770
which is going to be input dictionary value for our name shame.

619
00:51:17,930 --> 00:51:22,720
So we got that one of course we have to get that one as a string.

620
00:51:22,880 --> 00:51:28,580
So that's one of them let me copy that a few times even a little bit different but I'm going to copy

621
00:51:28,580 --> 00:51:30,160
them nonetheless.

622
00:51:30,460 --> 00:51:33,220
And at the end we have the else part for the guard.

623
00:51:33,230 --> 00:51:35,990
So the next thing is years.

624
00:51:36,020 --> 00:51:46,580
So I'm going to say here this is going to be years g and that is going to be an integer because I know

625
00:51:46,580 --> 00:51:54,150
that when we were producing it you know at the view controller I said here's Key is going to be an integer.

626
00:51:54,170 --> 00:51:59,340
So back into our Siddhant I'm going to say so we got here or there.

627
00:51:59,780 --> 00:52:01,090
Right.

628
00:52:01,120 --> 00:52:06,290
And when I say I got the name as a string I got the years as an integer.

629
00:52:06,350 --> 00:52:09,860
The next thing I need is I need to get the colorists string.

630
00:52:09,890 --> 00:52:12,020
So it's going to be color.

631
00:52:12,470 --> 00:52:18,200
I'm going to call this one color a string and you will see soon why I'm putting a different name for

632
00:52:18,200 --> 00:52:22,650
it so color key as a string and I need to get my status.

633
00:52:22,670 --> 00:52:25,920
So I'm going to say is that this again a string.

634
00:52:26,300 --> 00:52:28,520
And that's going to be a status cheat.

635
00:52:28,730 --> 00:52:33,630
Let me double check all of these names start the skin color Caig years skie name.

636
00:52:33,800 --> 00:52:40,540
So you know the view controller is that the Schaik your skin color key and Name Key perfect.

637
00:52:40,550 --> 00:52:42,730
So everything is exactly as it should be.

638
00:52:43,010 --> 00:52:50,800
And now I'm going to say if all of this went well what they wanted to do which is no surprise.

639
00:52:50,840 --> 00:52:52,010
I want to sell.

640
00:52:52,110 --> 00:52:59,930
It's not that I want to end it with the other in the original in it are the designated in it as we call

641
00:52:59,930 --> 00:53:03,650
it otherwise I want to return that yes.

642
00:53:03,950 --> 00:53:06,450
So that part is taking care of.

643
00:53:06,470 --> 00:53:11,810
Now the problem the challenge we have is a few things name is there.

644
00:53:11,930 --> 00:53:13,650
That's perfectly fine.

645
00:53:13,750 --> 00:53:15,250
Yours is there.

646
00:53:15,470 --> 00:53:17,170
That's also perfectly fine.

647
00:53:17,180 --> 00:53:18,820
Aponte I spelt it wrong.

648
00:53:18,830 --> 00:53:24,260
I called it Max years not Max years but you know you know what that is.

649
00:53:24,260 --> 00:53:31,130
These two however are rather simple simply because the value that they have for the state is a string

650
00:53:31,390 --> 00:53:33,680
and I can't use a string for what they need.

651
00:53:33,680 --> 00:53:37,770
I actually need to get it as a Vache real estate you know.

652
00:53:38,060 --> 00:53:42,310
So I'm really going say OK here's what you're going to do.

653
00:53:42,320 --> 00:53:44,780
You got to say valuable.

654
00:53:44,970 --> 00:53:46,290
Stop this.

655
00:53:46,310 --> 00:53:47,270
I'm going to put it away.

656
00:53:47,270 --> 00:53:49,770
The font to be available.

657
00:53:50,150 --> 00:54:00,660
Then you're going to say for any case in the killer state not all the case says he does what you want

658
00:54:00,660 --> 00:54:01,320
to do.

659
00:54:01,410 --> 00:54:13,110
You want to say if the status is or was there value that you have in any case as a string.

660
00:54:13,260 --> 00:54:17,480
So I'm going to say interpretated as a string.

661
00:54:17,850 --> 00:54:21,740
If that was the case then here's what you want to do.

662
00:54:21,780 --> 00:54:27,870
You want to change your status to become a death case any case.

663
00:54:27,870 --> 00:54:31,520
I think I should have used the were all cases yes.

664
00:54:31,530 --> 00:54:33,310
So using this.

665
00:54:33,360 --> 00:54:34,010
What they didn't.

666
00:54:34,020 --> 00:54:41,430
I managed to convert to whatever we found in here as this thing went through all the cases and I found

667
00:54:41,430 --> 00:54:47,350
it as not strange rather a case from this on.

668
00:54:47,550 --> 00:54:50,590
So now we can use this stock this year.

669
00:54:50,790 --> 00:54:58,570
And finally to probably the most difficult one and that is how are we going to get a colorists throwing

670
00:54:58,680 --> 00:55:05,700
which is a string and convert it to an actual You eye color because he in here is expecting us to give

671
00:55:05,700 --> 00:55:09,240
it the color the color of once a color.

672
00:55:09,450 --> 00:55:13,130
So we have to do the opposite of what we did here in the past.

673
00:55:13,130 --> 00:55:16,120
He said you like color plus name.

674
00:55:16,320 --> 00:55:20,370
Now we have to say is string plus color.

675
00:55:20,370 --> 00:55:22,070
So we have to get the opposite effect.

676
00:55:22,080 --> 00:55:24,820
So I want to go start a news fine.

677
00:55:25,020 --> 00:55:27,740
I'm going to call it a string class.

678
00:55:28,110 --> 00:55:31,460
Color or color or whatever you want to call it.

679
00:55:31,820 --> 00:55:37,100
And in here I'm going to have to import you I hit him for you.

680
00:55:37,100 --> 00:55:41,600
I get I'm going to say that's an extension or a string.

681
00:55:41,610 --> 00:55:44,760
So it adds something to a string.

682
00:55:44,760 --> 00:55:54,570
What it does it says color of the type you eye color is going to be switch self.

683
00:55:54,840 --> 00:56:02,010
So it shot through its sewage south and here's what I want to see in the switch.

684
00:56:02,190 --> 00:56:04,940
I want to see that for Chase.

685
00:56:05,010 --> 00:56:10,260
Let's say black you have to return what should they return.

686
00:56:10,260 --> 00:56:16,020
I have to return you I color dot black and white is the complete list stuff.

687
00:56:16,030 --> 00:56:17,650
This is these guys.

688
00:56:17,700 --> 00:56:20,120
Everyone in here should be returned.

689
00:56:20,160 --> 00:56:26,460
Similarly someone going here and say hey it's paste all of that and I'm going to pause the video to

690
00:56:26,490 --> 00:56:27,230
clean these.

691
00:56:27,270 --> 00:56:28,930
So bear with me for a second.

692
00:56:29,190 --> 00:56:37,210
So what I have is in mutant or in your variable from any string that may return a color.

693
00:56:37,490 --> 00:56:44,070
And in case that the string is black is going to return your white color after lie in in case that string

694
00:56:44,070 --> 00:56:46,540
you sign on is going to bring you eye color.

695
00:56:46,550 --> 00:56:47,230
That.

696
00:56:47,490 --> 00:56:52,200
So let's go back to my site and see done.

697
00:56:52,420 --> 00:57:01,650
And yeah I'm going to say get the eye color from color tiara and then from the colors the are yet dot

698
00:57:01,890 --> 00:57:06,660
color and I'm going to force on drop it because I know that thing exists.

699
00:57:06,660 --> 00:57:15,380
So with that in mind now that we have all chameleons in it but we added things just a tiny bit so we

700
00:57:15,390 --> 00:57:17,770
can see them a little bit easier.

701
00:57:18,330 --> 00:57:23,280
Everything in one screen now that we can fit into a dictionary.

702
00:57:23,310 --> 00:57:26,200
I'm yet to back a C Don.

703
00:57:26,340 --> 00:57:32,490
I'm going to go back to my idea view controller and in here I'm going to go ahead and say let's do a

704
00:57:32,490 --> 00:57:34,230
few things.

705
00:57:34,410 --> 00:57:43,360
I'm going to say if they didn't work just return don't do anything I don't else as such.

706
00:57:43,500 --> 00:57:46,430
Then I'm going to say valuable new we can.

707
00:57:46,510 --> 00:57:49,030
It is going to be of that type.

708
00:57:49,500 --> 00:57:55,980
And then I'm going to say if selected type is sit down here's what they want to happen.

709
00:57:56,040 --> 00:58:01,380
I want the new color to be seen on all

710
00:58:04,290 --> 00:58:12,780
of the input dictionary and that is going to be new vehicle dictionary if I do that and I successfully

711
00:58:12,780 --> 00:58:14,860
produce a new vehicle.

712
00:58:15,000 --> 00:58:16,050
Here's what they want to do.

713
00:58:16,050 --> 00:58:21,490
I want to say dummies not dummies array dot a.

714
00:58:21,600 --> 00:58:23,010
And what would you want to happen.

715
00:58:23,010 --> 00:58:25,620
I want to append the new vehicle.

716
00:58:25,950 --> 00:58:32,090
So this way every time we pressed the odd action we test if it is valid.

717
00:58:32,520 --> 00:58:39,210
We do this we make a new we can of course you can imagine the other side the IT WOULD BE else or else

718
00:58:39,300 --> 00:58:45,220
if you want it selected type is tried are you have to do something else in here.

719
00:58:45,240 --> 00:58:50,100
I'm not doing that simply because I haven't written the code for that's right and I'm not going to do

720
00:58:50,100 --> 00:58:54,310
it because it's going to be very very similar to what we have in here.

721
00:58:54,330 --> 00:59:00,510
So in here I'm going to say let's dismiss the and if it was unsuccessful just go ahead and test our

722
00:59:00,510 --> 00:59:01,830
application.

723
00:59:02,490 --> 00:59:08,970
If it all works we should be able to add the carrots through our art and then read them back at our

724
00:59:09,270 --> 00:59:10,230
main view.

725
00:59:10,230 --> 00:59:21,860
So right now we have available for and dodge and out Crolla repairs Fiat and sedans Crolla forward and

726
00:59:22,090 --> 00:59:31,080
it's not like going here and they have a sedan by the name of people and the color is say sign on.

727
00:59:31,350 --> 00:59:37,230
And then I've got Mike Schiro one is quietly available and I'm going to add it.

728
00:59:37,350 --> 00:59:42,400
One is that you automatically are transitioning back to our main view controller.

729
00:59:42,450 --> 00:59:45,020
I can go to available is here now.

730
00:59:45,270 --> 00:59:48,610
So we either had one successfully in here.

731
00:59:48,990 --> 00:59:53,200
So that's pretty much the end of this very long lesson.

732
00:59:53,250 --> 01:00:01,320
So we began by having an interface that has our view as one of them shows a number of objects in an

733
01:00:01,380 --> 01:00:02,250
array.

734
01:00:02,250 --> 01:00:04,800
The other one can produce a new one.

735
01:00:04,860 --> 01:00:09,740
We try to split our code into as many extensions on as we could.

736
01:00:09,750 --> 01:00:15,660
Right now our application isn't all that extensive but even now it's over a hundred lines and you can

737
01:00:15,660 --> 01:00:19,430
see going through all of these might be a little bit tedious.

738
01:00:19,530 --> 01:00:25,020
You have to break all of these into separate extensions or if you're working in Objective-C separate

739
01:00:25,020 --> 01:00:26,010
categories.

740
01:00:26,130 --> 01:00:29,230
So every part is going to work you know independently.

741
01:00:29,370 --> 01:00:35,100
I'm going to actually pause the video and do that in a second now and then show you how it would be

742
01:00:35,100 --> 01:00:38,880
if it was a real life practice.

743
01:00:38,880 --> 01:00:44,730
So what I have done while the video was on pause I have actually broken my ad the view controller in

744
01:00:44,790 --> 01:00:47,210
as many extensions as I could.

745
01:00:47,220 --> 01:00:52,800
One of them is the main view controller which has all the declarations and it has the view that lot

746
01:00:53,110 --> 01:00:57,690
and I have the populates color into a new extension.

747
01:00:57,870 --> 01:01:04,680
I have the text fields delegation are changing the color changing the gears changing the start changing

748
01:01:04,680 --> 01:01:06,170
the type.

749
01:01:06,190 --> 01:01:08,540
Validate an odd action.

750
01:01:08,550 --> 01:01:14,010
Now this really helps you or any other developer who wants to read your code later on so that they can

751
01:01:14,010 --> 01:01:20,100
easily go to I don't know the part that changes Stathis read only a few lines of code and they understand

752
01:01:20,100 --> 01:01:21,330
what's going on.

753
01:01:21,690 --> 01:01:26,700
So with that in mind let's close this lesson it became a very very long one.

754
01:01:26,700 --> 01:01:28,090
I apologize for that.

755
01:01:28,120 --> 01:01:34,080
And like I say it wasn't meant for you to follow along it was just more of a demonstration of how you

756
01:01:34,080 --> 01:01:35,910
should think about your development.

757
01:01:35,920 --> 01:01:40,590
There is of course a million things still you can add to this application and I actually encourage you

758
01:01:40,590 --> 01:01:41,870
to do it.

759
01:01:41,880 --> 01:01:47,600
Go ahead and get the you know the convenience in it from sit down and added to the to the truck you

760
01:01:47,630 --> 01:01:50,070
know class and change stuff in here.

761
01:01:50,220 --> 01:01:56,480
Troy to our customer tributes to either of the classes so you understand how each of them work of work

762
01:01:56,480 --> 01:02:02,250
here on your income to have more values in there and you can actually expand on this application once

763
01:02:02,320 --> 01:02:06,630
you learn other tools such as your table views or collection views.

764
01:02:06,810 --> 01:02:12,510
You can start adding images for each of them you can have some built in images within the bundle of

765
01:02:12,510 --> 01:02:15,100
your application on the main view of your app.

766
01:02:15,240 --> 01:02:20,110
You can have a little photo for it that you can see each of them with a little picture.

767
01:02:20,110 --> 01:02:25,750
There are a million things you can do and I really suggest that you guys work on them and try to to

768
01:02:25,830 --> 01:02:30,740
you know expand on that as you can see everything that we did in this happy cation.

769
01:02:30,740 --> 01:02:36,750
Our thing is that we already study it but it's not necessarily used the way that we do it in the in

770
01:02:36,750 --> 01:02:41,190
the lessons because when you want to practice them things become a little different.

771
01:02:41,430 --> 01:02:47,040
Perhaps at the beginning of the development none of us thought that we need to find a way to change

772
01:02:47,040 --> 01:02:51,910
the outcome where the names of the colors into a Strange's or the opposite.

773
01:02:51,920 --> 01:02:56,200
You have to convert the names of the streams into actual callers.

774
01:02:56,320 --> 01:03:03,570
So these things you only learn them by practice so that I will see you in our next.
