1
00:00:00,100 --> 00:00:06,390
But come back again in this exercise you're supposed to be developing a shopping list application that

2
00:00:06,390 --> 00:00:12,600
is similar to a To Do list they use they can add new items and then every once in a while an item is

3
00:00:12,600 --> 00:00:12,960
done.

4
00:00:12,960 --> 00:00:17,070
They can mark them as done or they could essentially delete an item.

5
00:00:17,250 --> 00:00:22,050
I've actually developed the application for you so I can show you in advance why it looks like this

6
00:00:22,050 --> 00:00:23,010
is the application.

7
00:00:23,010 --> 00:00:29,490
It has a table view controller that shows us some items right now Brett is already purchased.

8
00:00:29,490 --> 00:00:35,100
Milk has to be purchased and if I want to add some new items to my list they could go up here in my

9
00:00:35,100 --> 00:00:41,520
text field and say I need to buy potatoes and that one gets added Maybe I need to buy some tomatoes

10
00:00:41,520 --> 00:00:41,840
as well.

11
00:00:41,850 --> 00:00:46,040
And that's what also gets added every time I touch any of the cells.

12
00:00:46,050 --> 00:00:52,430
That's one changes their status so if it is not purchased it becomes purchased and if it is purchased

13
00:00:52,430 --> 00:00:54,120
I may need to re purchase it.

14
00:00:54,420 --> 00:00:58,050
I can copy the gain and make it active for more time.

15
00:00:58,050 --> 00:01:04,130
And of course if I wanted I could actually delete one of my cells if I don't want to buy a milk anymore.

16
00:01:04,140 --> 00:01:06,480
If that's out of my shopping list.

17
00:01:06,480 --> 00:01:11,760
So that's the goal of the exercise and let us pause the video now for a few seconds.

18
00:01:11,760 --> 00:01:15,250
This gives you a time to pause the video as well and go along.

19
00:01:15,480 --> 00:01:20,250
Developing the application on your own or if you wanted to you could just get us started with me in

20
00:01:20,250 --> 00:01:21,510
just a few seconds.

21
00:01:25,010 --> 00:01:26,570
So let's go ahead and get started.

22
00:01:26,570 --> 00:01:27,740
I'm going to export.

23
00:01:27,770 --> 00:01:37,310
I'm going to start a new application called my shopping list app and my shopping list application.

24
00:01:37,310 --> 00:01:44,180
What I'm going to be doing is I'm going to make a new file which is of the type you a table view controller.

25
00:01:44,630 --> 00:01:49,630
So this is the one I'm when I call on my table view controller.

26
00:01:49,910 --> 00:01:54,410
A better name for this file would be IDM them table view controller.

27
00:01:54,410 --> 00:01:58,820
Simply because this is where you're going to see the items of our shopping list.

28
00:01:58,820 --> 00:02:04,610
The reason I'm suggesting that is because you might have an application that has multiple lists and

29
00:02:04,610 --> 00:02:07,580
then each list has a group of items.

30
00:02:07,580 --> 00:02:12,260
So maybe you would you know care about the naming convention you're using.

31
00:02:12,260 --> 00:02:18,970
So for now when I call them items table view controller even though we don't have a lists table of your

32
00:02:18,980 --> 00:02:22,160
controller so I don't need the view controller anymore.

33
00:02:22,160 --> 00:02:27,360
I'm going to delete that and I'm going to head into the storyboard deletes my view controller outlet.

34
00:02:27,410 --> 00:02:29,920
Make a table view controller.

35
00:02:30,020 --> 00:02:37,100
That table view contorted and then I say it's class is going to be Items table view controller and it

36
00:02:37,190 --> 00:02:39,730
also is my initial view controller.

37
00:02:39,750 --> 00:02:41,780
So it starts to application.

38
00:02:41,780 --> 00:02:48,770
Then I'm let it go and select my table view say maybe I want to have a slightly higher raw height maybe

39
00:02:48,770 --> 00:02:54,270
56 or each row is a little bit taller and then I'm going to select the cell.

40
00:02:54,320 --> 00:03:01,160
Say my cell has an idea such as cell I.D. And it's of the type of basic.

41
00:03:01,160 --> 00:03:09,470
And finally unless like my table view say my separator is tied is single line and my separator has a

42
00:03:09,470 --> 00:03:10,480
blue color.

43
00:03:11,000 --> 00:03:17,470
And that's all I'm going to be doing in here for my table view v team a storyboard.

44
00:03:17,510 --> 00:03:22,710
Next thing I'm going to do is I'm going to head into items table to view controller in here.

45
00:03:22,760 --> 00:03:29,900
I'm going to go ahead and say I don't need the number of sections for the number off the rose for now

46
00:03:29,900 --> 00:03:36,020
I'm just going to say there is a static number such as 10 because I want to be able to see some things

47
00:03:36,020 --> 00:03:40,640
in my table view controller and for the cell for raw index.

48
00:03:40,660 --> 00:03:45,460
But I'm going to go ahead and say why I don't need anybody else for here.

49
00:03:45,470 --> 00:03:55,310
Well they would need is to make a cell from cell I.D. And I want to say cell the text they've mean that

50
00:03:55,310 --> 00:04:04,490
text becomes item and that's all I'm going to be doing to see 10 items in my table view controller.

51
00:04:04,490 --> 00:04:10,070
Now before they're on my application I'm actually gonna go ahead and add the text field on top of my

52
00:04:10,070 --> 00:04:15,770
table view as of it and to do that I'm going to go to my view did load in here I'm going to go ahead

53
00:04:15,770 --> 00:04:23,210
and say I have something called a header text field and that's going to become a UI text field.

54
00:04:23,570 --> 00:04:29,810
And the UAE thinks they need to make it a frame and the frame I need to have is the frame of the header

55
00:04:29,840 --> 00:04:34,100
a view of my table view but they don't have that so I actually have to make it.

56
00:04:34,130 --> 00:04:40,550
So I'm going to say let head there frame and I'm going to make that to be a siege.

57
00:04:40,760 --> 00:04:44,230
Of these values and the values will be quite familiar to you.

58
00:04:44,360 --> 00:04:50,260
That top left corner of it will be zero and zero the height of it would be 56.

59
00:04:50,270 --> 00:04:53,120
That's the value that I put for each of the cells.

60
00:04:53,120 --> 00:05:00,470
So I'm putting the same value for the height of my text field and the veto if it would be self DOD table

61
00:05:00,470 --> 00:05:06,610
view dot bounds dot height or that width sorry dot of it.

62
00:05:06,890 --> 00:05:13,100
So I use the same value as the width of the table view to make the width of my header frame and that

63
00:05:13,100 --> 00:05:18,470
frame becomes the frame for my text field so I know they have that I'm going to actually go ahead in

64
00:05:18,470 --> 00:05:29,480
here and say self dot table view dot table had their view becomes header text field so my text field

65
00:05:29,600 --> 00:05:36,800
essentially becomes the header view for this table view I am however going to change a few things before

66
00:05:36,800 --> 00:05:41,070
I run the application and these are just simply matters of decoration.

67
00:05:41,150 --> 00:05:47,640
So I'm going to say Heather thinks sweep the text alignment becomes an ethics alignment that center.

68
00:05:47,690 --> 00:05:54,560
So that's a very easy one then I'm going to say it's funds becomes UI funds that system font of size

69
00:05:54,890 --> 00:06:02,450
let's make it larger such as maybe 20 and then I'm going to say it always has a place holder that says

70
00:06:02,450 --> 00:06:08,270
new item maybe question mark at the end of it and that's all I have to do in here.

71
00:06:08,360 --> 00:06:13,630
There is however one more thing that we have to do away it's not related to the looks of that expert

72
00:06:13,670 --> 00:06:21,860
it's rather about its functions and that is if you have to delegate from this text field tool here simply

73
00:06:21,860 --> 00:06:28,790
because I want to be able to use things such as text fields should return or text field did and editing

74
00:06:29,060 --> 00:06:34,730
and that's when the user ends typing something and hits enter and I want to add that as a new item.

75
00:06:35,000 --> 00:06:41,900
So I'm there have to add the UI text file delegate here I'm going to go up here and say Give me you

76
00:06:41,900 --> 00:06:50,540
I text field delegate let me reformat everything that is way pressing told AM I and then now we should

77
00:06:50,540 --> 00:06:57,140
have a text file on top of our table view and we should also see ten items that they just randomly say

78
00:06:57,260 --> 00:07:03,290
item let's go ahead and run our application I usually like to run my application when I'm developing

79
00:07:03,640 --> 00:07:09,590
in in less than once every half an hour that's kind of my rule to to make sure every half an hour when

80
00:07:09,590 --> 00:07:14,480
I'm at least running one so I know what I'm doing and that's kind of you know what I expected to see

81
00:07:14,480 --> 00:07:20,060
I'm seeing some items in here on top of it I'm seeing an item you know place holder that they can type

82
00:07:20,060 --> 00:07:22,520
something in there eyes all good to go.

83
00:07:22,670 --> 00:07:29,210
Now the next thing we have to do you have to be able to add some items to our application but before

84
00:07:29,210 --> 00:07:33,230
that we need to have an infrastructure for maintaining our data.

85
00:07:33,530 --> 00:07:38,860
So to do that I'm actually going to go ahead and add a new file is going to be a new Swift file and

86
00:07:38,870 --> 00:07:40,460
I'm going to call this one item.

87
00:07:40,460 --> 00:07:47,390
This is my IDM class that for each item that we make we will have one of these objects instantiate it

88
00:07:47,660 --> 00:07:52,080
so my item class will look like this it would be a very simple one.

89
00:07:52,160 --> 00:07:59,860
So it's a class and this class is called IDM doesn't have a super class it has a valuable called the

90
00:07:59,860 --> 00:08:07,040
name which is after type a string and also has a value of about it called a Stathis which is off the

91
00:08:07,040 --> 00:08:13,250
type boolean which essentially says this is the name of the item and this is a client the status is

92
00:08:13,250 --> 00:08:20,110
it already done or purchased or is it not done and not purchased only then in it for it.

93
00:08:20,110 --> 00:08:28,070
So I'm going to say in it and I'm going to say in name which is if string and an is not which is again

94
00:08:28,140 --> 00:08:29,180
a bullion.

95
00:08:29,300 --> 00:08:38,930
And of course now my name will be in name and my status as status will be imp is not this.

96
00:08:38,930 --> 00:08:40,760
And does all they have to do in here.

97
00:08:40,760 --> 00:08:45,760
I have an item class that can hold on to my various items.

98
00:08:45,780 --> 00:08:47,020
No they have not.

99
00:08:47,020 --> 00:08:52,370
They have to be able to somehow populate the initial data to do that.

100
00:08:52,370 --> 00:08:54,540
I'm actually going to go ahead and make a new fight.

101
00:08:55,250 --> 00:08:59,050
This new fun I'm going to call it my data.

102
00:09:01,110 --> 00:09:02,140
I need my data.

103
00:09:02,150 --> 00:09:12,230
I'm going to have a new class called class my data and then you know we'll have a static variable and

104
00:09:12,230 --> 00:09:18,320
I'm going to call it IBMs array which is an array of items.

105
00:09:19,490 --> 00:09:22,400
And then I could actually add a new class for it.

106
00:09:22,430 --> 00:09:24,410
Or you could do it built into here.

107
00:09:24,410 --> 00:09:27,410
I'm going to say that is a new class function.

108
00:09:27,410 --> 00:09:29,570
And this class function not like that.

109
00:09:29,600 --> 00:09:32,750
None of those autocomplete had the wrong stuff.

110
00:09:32,750 --> 00:09:34,610
So class function.

111
00:09:34,610 --> 00:09:37,810
I'm going to call it populate initialize.

112
00:09:37,820 --> 00:09:42,770
These are the very initial items and what they want are doing here is this I want to say that is lit

113
00:09:43,440 --> 00:09:46,520
IDM let's call it the one the name of it doesn't matter.

114
00:09:46,520 --> 00:09:53,710
It's an item with these information maybe it says bread and this that this is true.

115
00:09:54,140 --> 00:10:02,590
And then I have let I them to which is going to be item and this name is going to be maybe milk.

116
00:10:03,140 --> 00:10:05,960
And this not this is false.

117
00:10:05,960 --> 00:10:14,300
And then finally I'm going to say items array becomes an array of item one.

118
00:10:14,780 --> 00:10:20,690
And I them two I think they misspelled this one even though it doesn't really matter that.

119
00:10:20,720 --> 00:10:22,370
But they'd like to be okay.

120
00:10:22,970 --> 00:10:28,720
So now when they populate any shows gets called we will have some objects in our items.

121
00:10:28,730 --> 00:10:31,380
Eric and now let's go ahead and use that.

122
00:10:31,400 --> 00:10:37,780
I'm going to go back to my items table view controller in my view did Lord I'm gonna say right up there

123
00:10:37,790 --> 00:10:47,540
say my dad's dog populate any shots so I know that the array is now populated it has items in it because

124
00:10:47,540 --> 00:10:53,510
it has items in it I'm going gonna go ahead in here and say a number of rows is actually my daughter

125
00:10:54,260 --> 00:10:56,660
died items array that count.

126
00:10:56,660 --> 00:11:04,760
So find out how many are there instead of a static 10 put the numbers of the actual items in here in

127
00:11:04,760 --> 00:11:14,600
the table view I'm going to go ahead and say let this item them to be my data DOD items array object

128
00:11:14,600 --> 00:11:24,680
that index part that's raw so find that the item we want to show and then that item dot name becomes

129
00:11:24,680 --> 00:11:31,610
the name of this set there's a still a little bit more stuff we have to do in here depending on the

130
00:11:31,700 --> 00:11:38,390
status of the item we have to decide whether the text is shown in a normal day or if there is a stake

131
00:11:38,390 --> 00:11:43,250
through it also we want to change the background color of the cell I'm furious I want to show that tick

132
00:11:43,250 --> 00:11:49,460
mark on the far right corner of it but for now we can actually run the application like this just to

133
00:11:49,460 --> 00:11:54,390
get a sense of what's going going in here and if everything is working the way I was hoping is gonna

134
00:11:54,410 --> 00:11:59,780
be working if it all works we should be able to see bread and milk and we have the text filled up there

135
00:12:00,100 --> 00:12:05,450
and we could essentially go ahead and add then other stuff in here so far if it happened and nothing

136
00:12:05,450 --> 00:12:10,730
happens or we have to implement that and depending on the start this off then we have to change the

137
00:12:10,730 --> 00:12:16,190
way they look in the sets I'm also going to suggest one more thing and that is I want to change the

138
00:12:16,190 --> 00:12:21,890
background code of the text field because it feels very similar to the to the actual sets.

139
00:12:21,980 --> 00:12:28,550
So the first thing is that I'm going to come in here and say had the text field not background color

140
00:12:28,790 --> 00:12:36,850
becomes a UI color dot I actually don't want to use any of the existing colors I won't actually feed

141
00:12:36,850 --> 00:12:40,060
the three values for our G.B. an A.

142
00:12:40,070 --> 00:12:46,010
So the air which is the alpha becomes one I want it to have a 10 tough blue so I'm going to make the

143
00:12:46,010 --> 00:12:53,330
blue off it full of one and the other two guys a little bit less point eight for instance then next

144
00:12:53,330 --> 00:12:58,330
thing I'm going to do it before I do any other tests I'm going to come in here into my cell for routine

145
00:12:58,330 --> 00:13:05,110
next part and I'm going to say let's do this let's go ahead and say once we found the item and then

146
00:13:05,110 --> 00:13:15,320
I say if this item Dodd is Stathis if this item is already purchased all right I'm the assuming it's

147
00:13:15,320 --> 00:13:22,670
not this true means done so if it is purchased you want to do something and of course in the else you

148
00:13:22,670 --> 00:13:24,230
want to do something else.

149
00:13:24,230 --> 00:13:32,240
Two of the things I say rather simple if it is purchased I want to say do sell the background color

150
00:13:32,570 --> 00:13:38,130
become UI color dot light great and that's very simple.

151
00:13:38,240 --> 00:13:42,660
And if it is not I want to make it become white.

152
00:13:42,830 --> 00:13:50,570
Also if it's status is true I'm going to go ahead and say Sell dot accessory type becomes a UI table

153
00:13:50,570 --> 00:13:54,260
view so that accessory type dot checkmark.

154
00:13:54,260 --> 00:13:56,780
So show me a checkmark on the far right.

155
00:13:56,960 --> 00:14:01,130
And if it is not then do this say none.

156
00:14:01,130 --> 00:14:03,050
So it doesn't show that.

157
00:14:03,080 --> 00:14:09,770
So so far we have managed to set the background color and also set the check and if you run the application

158
00:14:09,770 --> 00:14:15,790
now we should be able to see are cells that they show the mark under fire right.

159
00:14:15,800 --> 00:14:18,080
If they are purchased and they don't.

160
00:14:18,080 --> 00:14:22,850
If they are not and everything is the way that we're hoping it's going to be the only thing we still

161
00:14:22,850 --> 00:14:27,260
have to do is we have to put a streak through this and for doing that we have to use something that

162
00:14:27,260 --> 00:14:29,760
is called a tribute to the string.

163
00:14:29,780 --> 00:14:32,750
So let's go ahead and do that to use an app to rehearse thing.

164
00:14:32,750 --> 00:14:33,710
Here's what I'm going to do.

165
00:14:33,710 --> 00:14:41,840
The very first thing is once I found my item I'm going to come in here and say let 80 t are a string.

166
00:14:42,020 --> 00:14:48,620
I'm going to say that it becomes an N S immutable attribute to the string and the string that we want

167
00:14:48,620 --> 00:14:53,120
to use for that is actually the name of this item.

168
00:14:53,180 --> 00:14:55,670
So this item got a name.

169
00:14:55,970 --> 00:15:02,480
So let's remove the strings they allow us to add new attributes to their specific parts of a string.

170
00:15:02,480 --> 00:15:07,190
For instance you can have this thing to the part of it is a different color or a string that the part

171
00:15:07,190 --> 00:15:10,280
of it is bought than the rest of it is in a normal font.

172
00:15:10,280 --> 00:15:14,200
So on and so forth there's so much you can be doing and here what they want to do.

173
00:15:14,210 --> 00:15:17,570
I want to use something that's called a strike truest style.

174
00:15:17,810 --> 00:15:21,980
So if a status is true I want to do this.

175
00:15:21,980 --> 00:15:29,450
I want to go ahead and say a t business string dot add attribute and get tribute that they want to add.

176
00:15:29,480 --> 00:15:38,980
Is this is a. attributed a string dot she and the kids they want to add is strike true color.

177
00:15:39,100 --> 00:15:40,450
A state through a state.

178
00:15:41,180 --> 00:15:48,620
So their value for it is the next thing which is essentially the vit of the line that strikes through

179
00:15:48,620 --> 00:15:54,050
the text I'm going to say that's two point zero and the range for it is the range of the characters

180
00:15:54,050 --> 00:15:54,850
that they want to use.

181
00:15:54,860 --> 00:15:59,650
And I want to use every character in this name which is the name of my item.

182
00:15:59,840 --> 00:16:08,870
So I'm going to say Ennis mage range and my inner snake range the values that is thought on and are

183
00:16:08,870 --> 00:16:17,780
zero and then 80 are a string that left so go from the beginning to the end defeat for all of them at

184
00:16:17,780 --> 00:16:19,750
this particular side.

185
00:16:19,760 --> 00:16:24,620
So now if an item is purchased is going to see a strike through it.

186
00:16:24,620 --> 00:16:27,620
We do however want to remove this attribute.

187
00:16:27,800 --> 00:16:33,530
If we are not purchased and to do that I'm actually going to copy this because I want to simplify my

188
00:16:33,530 --> 00:16:34,280
life.

189
00:16:34,490 --> 00:16:38,210
And in here I'm going to say I don't want to add an item reboot.

190
00:16:38,240 --> 00:16:44,990
I want to remove attributes and remove that attribute this is the attribute I want to remove and it

191
00:16:44,990 --> 00:16:46,850
doesn't have a value anymore.

192
00:16:46,850 --> 00:16:50,780
So I just want to remove the attribute within this range.

193
00:16:50,780 --> 00:16:57,350
So I'm going to say remove that attribute attribute key strike to its nine and remove it from this particular

194
00:16:57,350 --> 00:17:00,380
range which is the entirety of this thing.

195
00:17:00,400 --> 00:17:07,340
Now so far we haven't seen the string but it doesn't mean he's going to show up any of it because we

196
00:17:07,340 --> 00:17:09,810
actually have to apply it to our labor.

197
00:17:09,980 --> 00:17:17,550
So I'm going to come in here and say Sell instead of the text label text say text label dot attribute

198
00:17:17,550 --> 00:17:21,220
that text becomes 80 or a string.

199
00:17:21,230 --> 00:17:24,710
So this is probably a new thing at least in this course.

200
00:17:24,710 --> 00:17:30,050
You guys probably have seen it in the past but I think with the text essentially allows us to instead

201
00:17:30,050 --> 00:17:37,040
of the regular text allows us to put an attribute that text within our text leave it the square then

202
00:17:37,040 --> 00:17:42,860
run our application and if it all goes then we should be able to see sell as of it their final look

203
00:17:42,890 --> 00:17:48,310
the way we want them to to show up essentially and that's exactly what we wanted to see.

204
00:17:48,320 --> 00:17:53,840
The one that is purchased has a checkpoint answer stricken through but the other one is showing us you

205
00:17:53,960 --> 00:17:59,270
know might be the next thing I want to do is I want to be able to tap on any of the cells and I want

206
00:17:59,270 --> 00:18:03,060
to make sure that that cell essentially gets to reverse.

207
00:18:03,160 --> 00:18:10,130
A status which is a very simple thing here I'm going to add a bit select throughout in the spots in

208
00:18:10,130 --> 00:18:14,990
the select why then next might actually need this exactly as it was before.

209
00:18:15,380 --> 00:18:22,450
So I'm going to find the item which is my dad the items index cards whatever the status of it is.

210
00:18:23,030 --> 00:18:26,890
I'm going to make it become whatever they start as if it was.

211
00:18:26,990 --> 00:18:30,890
So I'm going to reverse its a status once that is done.

212
00:18:30,920 --> 00:18:35,460
I'm going to say table view the reload data and that's about that.

213
00:18:35,480 --> 00:18:40,700
Now with only three lines of code we're able to reverse the status of an item.

214
00:18:40,850 --> 00:18:46,380
And if you're here we type on milk it gets reversed or bread it gets reversed their final thing we after

215
00:18:46,400 --> 00:18:52,790
doing here is when we go to the text feed and we type something like potato I could use my keyboard

216
00:18:52,790 --> 00:18:58,720
or I could use the soft keyboard in here and we had entropy one that one to get added in yet.

217
00:18:59,030 --> 00:19:06,080
So let's go ahead in here and that method the method is essentially called text field should the return

218
00:19:06,080 --> 00:19:11,440
should return sort of text which should return is something that we have seen in the past.

219
00:19:11,580 --> 00:19:15,750
And the first thing you want to do is we want to say text with the other design the first responder

220
00:19:16,050 --> 00:19:24,540
to get rid of the keyboard then I'm going to go ahead and say if let me your name is text field dot

221
00:19:24,570 --> 00:19:33,720
text if my user has actually entered a value we have to make a new item and in the hours we have to

222
00:19:33,780 --> 00:19:37,540
not make a new item we just have to return false.

223
00:19:37,890 --> 00:19:45,930
So if we had a new item we have to return true but before returning true we have to actually make our

224
00:19:45,930 --> 00:19:51,490
new item which making a new item is actually rather simple is like this I'm going to go in here and

225
00:19:51,510 --> 00:20:01,350
say let new I then become IDM and the item is based on then your name and as a start this is definitely

226
00:20:01,350 --> 00:20:07,050
false because a new item B can't have it already done or purchased essentially.

227
00:20:07,290 --> 00:20:14,250
Then I'm going to go ahead and say my other dot every dot append new item to itself.

228
00:20:14,730 --> 00:20:19,880
So now we have an array that has the latest item added to itself.

229
00:20:19,890 --> 00:20:25,440
So at this point you could do two things Either you could simply say table view reload the data that

230
00:20:25,440 --> 00:20:30,270
shows it to you or you could actually insert a new cell.

231
00:20:30,450 --> 00:20:34,320
So that would give you us a little bit of an animation as of Sunday actually do that.

232
00:20:34,620 --> 00:20:42,810
So I'm going to say self that table view DOD begin updates and since I'm beginning the update at some

233
00:20:42,810 --> 00:20:48,500
point they have to say self that the table view that end updates between these two.

234
00:20:48,520 --> 00:20:55,810
I have to essentially go in here and say s dot table view dot insert rows.

235
00:20:55,830 --> 00:20:58,590
He's asking me so where do you want to insert it.

236
00:20:58,620 --> 00:21:04,170
And with what kind of animation I'm going to say Roll that animation make it fade in.

237
00:21:04,200 --> 00:21:10,470
So that part is taken care of but then you're saying you raise the index card that you want to add something

238
00:21:10,790 --> 00:21:17,310
and that is important because this index might not only knows in reach rule in this cell it should appear

239
00:21:17,640 --> 00:21:20,980
it also knows in which section it should appear.

240
00:21:21,030 --> 00:21:27,290
So to do that I'm going to go ahead in here and say let new I them index part.

241
00:21:27,330 --> 00:21:30,120
So this is the index math for the new item.

242
00:21:30,150 --> 00:21:33,210
It's going to become an index not Vit.

243
00:21:33,210 --> 00:21:38,150
These values they index Miles can have rows and sections.

244
00:21:38,190 --> 00:21:44,800
So two things section of it is always zero because in this application we only have one section there

245
00:21:44,820 --> 00:21:46,010
rule of it.

246
00:21:46,020 --> 00:21:51,060
I want it to be at the end of everything and the end of everything is very simple.

247
00:21:51,060 --> 00:21:56,740
That is my data dots are a dot count minus one.

248
00:21:56,760 --> 00:22:03,000
So if for instance I have six items I have to go and place my object at location five.

249
00:22:03,150 --> 00:22:09,900
And that's all we have to do new item index map becomes the only member of this array and before I run

250
00:22:09,900 --> 00:22:13,710
the application I will do one small you know housekeeping as well.

251
00:22:13,740 --> 00:22:23,100
And that is if you're successful I'm going to say text field dot text becomes empty again simply because

252
00:22:23,130 --> 00:22:26,480
I want to get rid of the name that is already in the text field.

253
00:22:26,490 --> 00:22:32,010
Now before I run the application I'm actually going to add one more item in here because I know that's

254
00:22:32,010 --> 00:22:35,280
something that you have done many many times and it's very easy.

255
00:22:35,280 --> 00:22:44,750
So I can edit rule return through yes it can be edited and then in the comment editing the snide comments

256
00:22:44,860 --> 00:22:52,170
I think I'm going to go ahead and say for my table view if I was committing a and editing I'm not going

257
00:22:52,170 --> 00:22:59,040
to check for the estate because I know what style it is as asking me to add the overriding year I'm

258
00:22:59,040 --> 00:23:07,400
going to say if it comes it anything your style was happening do this say table view dot delete and

259
00:23:07,410 --> 00:23:15,860
I want to delete the rules at this index part array and I want to have the same animation as fade.

260
00:23:15,870 --> 00:23:20,430
We do however have to remove that object from our array as well.

261
00:23:20,670 --> 00:23:29,180
So to do that I'm going to say my data dot array dot to remove at index.

262
00:23:29,270 --> 00:23:30,340
That's rule.

263
00:23:30,480 --> 00:23:32,250
And that's all we have to be doing.

264
00:23:32,250 --> 00:23:38,200
Two lines of quotes and let's run the application and by now we should be able to see or write them

265
00:23:38,280 --> 00:23:42,710
to change the status to add new items and of course to delete items.

266
00:23:42,840 --> 00:23:45,940
I'm going to go in here and say I don't wonder manage perfect.

267
00:23:45,990 --> 00:23:51,560
I don't wonder bread perfect by what they do want is maybe potato.

268
00:23:51,630 --> 00:23:57,070
And that shows up there enter and there may be I want to buy milk again.

269
00:23:57,270 --> 00:24:03,970
So Malik enter and if I want I can change the status and if I want it I could delete them.

270
00:24:04,020 --> 00:24:09,960
Now while this application is very interesting and it works well there is a still a very big missing

271
00:24:09,960 --> 00:24:13,770
part of it and that is they currently have put data in here.

272
00:24:13,770 --> 00:24:19,170
And if I go in here tonight every year on my application which is like you're relaunching your application

273
00:24:19,170 --> 00:24:24,380
on your device I will lose potato and I will be back to bread and manage.

274
00:24:24,570 --> 00:24:28,520
And that is because we don't have a press system that's on this application.

275
00:24:28,590 --> 00:24:31,140
That is something that is coming up in a few sections.

276
00:24:31,140 --> 00:24:37,620
When we talk about is storing data to the local hard disk of your mobile phone and it's obviously a

277
00:24:37,620 --> 00:24:40,770
very important aspect of of any development.

278
00:24:40,770 --> 00:24:42,920
But for now let's keep it up to here.

279
00:24:42,930 --> 00:24:48,480
We have a shopping list application that at least within one session it can work very well.

280
00:24:48,480 --> 00:24:50,370
It shows us everything that we need.

281
00:24:50,400 --> 00:24:56,970
I encourage you to take this application to the next level try to add another view controller that shows

282
00:24:56,970 --> 00:25:04,620
you different lists and then each list has a group of items maybe one list is for your grocery shopping

283
00:25:04,860 --> 00:25:10,710
and then other list is for some other random stuff that you want to buy throughout the VIX.

284
00:25:10,950 --> 00:25:14,940
So have two lists and each list having their own items.

285
00:25:14,940 --> 00:25:18,480
And good luck with that and let's move on to our next lesson.
