1
00:00:00,200 --> 00:00:06,930
So or come back in this class and begin to talk about a very important topic of reference counting reference

2
00:00:06,930 --> 00:00:13,440
counting is essentially vaid that you assign your memories and how you decide whether a new value of

3
00:00:13,650 --> 00:00:19,130
your property is going to have its own memory space or whether it is going to point to another memory

4
00:00:19,130 --> 00:00:25,230
as ways and how often they do get are located and how often they get released.

5
00:00:25,230 --> 00:00:32,080
Now the first counting is specifically in Objective-C is not the easiest thing to teach and to learn

6
00:00:32,400 --> 00:00:38,080
but there are some very good practices that simplify this for us in this case and I will go through

7
00:00:38,850 --> 00:00:44,460
almost all of the reference counting strategies that are out there and I will try to come up with some

8
00:00:44,460 --> 00:00:50,850
of the easiest ones for you so you can use them something you want to keep in mind is that you probably

9
00:00:50,850 --> 00:00:57,510
are not going to use any of these for a very very long time for the most part you can actually stick

10
00:00:57,510 --> 00:01:01,100
with the default ways of doing things and nothing is going to go wrong.

11
00:01:01,230 --> 00:01:06,510
But then the time will come that you are doing something a little bit more complicated and you have

12
00:01:06,510 --> 00:01:12,360
objects that they have internal references to each other and then you need to know how to deal with

13
00:01:12,360 --> 00:01:12,930
those.

14
00:01:13,140 --> 00:01:21,000
So with that in mind the squarehead into Estcourt and in code I'm going to start a new app command line

15
00:01:21,000 --> 00:01:22,660
tool Objective-C.

16
00:01:22,710 --> 00:01:25,040
I'm going to call it R R.

17
00:01:25,380 --> 00:01:31,050
And Orkus stands for automatic reference counting that's like the closest thing you can find in our

18
00:01:31,050 --> 00:01:38,610
X code for garbage collection for finding what object is no more in use and has to be released and what

19
00:01:38,610 --> 00:01:43,480
objects they have to stay in their stack because somebody is still accessing them.

20
00:01:43,800 --> 00:01:46,030
Well I'll call this one Aurukun.

21
00:01:46,130 --> 00:01:49,480
Let's say read or read right.

22
00:01:49,620 --> 00:01:54,260
Because that's the first thing that they want to talk about and of course these Objective-C

23
00:01:57,920 --> 00:02:10,140
then the yeah I'm going to go ahead and say I have a class interface let's call it my class.

24
00:02:10,170 --> 00:02:14,640
It has a superclass of this object.

25
00:02:15,330 --> 00:02:22,450
And then of course I need to have my implementation of my class and in my implementation I have nothing.

26
00:02:22,470 --> 00:02:27,970
Because simply just want introduce some properties as property envenomed.

27
00:02:28,020 --> 00:02:38,160
I'm going to make it like this and when I say it is atomic it is also read write and it is also strong.

28
00:02:38,700 --> 00:02:46,370
And I'm going to call this one the full string.

29
00:02:46,470 --> 00:02:47,430
So what does it mean.

30
00:02:47,430 --> 00:02:51,050
This is the default behavior of Objective-C.

31
00:02:51,060 --> 00:02:59,610
It means when you define any variables by default they get to become atomic read right and strong.

32
00:02:59,610 --> 00:03:06,120
So theoretically writing this line and writing this one are exactly the same thing.

33
00:03:06,180 --> 00:03:10,280
It would automatically would have those qualifiers added to it.

34
00:03:10,320 --> 00:03:14,480
I'm going to call this one or fall the string.

35
00:03:14,580 --> 00:03:15,900
So that's the easiest thing.

36
00:03:15,900 --> 00:03:17,370
So we got that out of the way.

37
00:03:17,370 --> 00:03:23,850
Now what is difficult or not difficult but what we need to discuss is so what all these things you know

38
00:03:23,850 --> 00:03:26,790
what do we do with them and how do we use them.

39
00:03:26,970 --> 00:03:28,460
Let's go ahead and get started.

40
00:03:28,470 --> 00:03:31,780
The most basic one which is this one reads right.

41
00:03:32,040 --> 00:03:38,910
I'm going to say I have a property and that property has only one qualifier hard to read right and then

42
00:03:38,910 --> 00:03:40,190
I have the same thing.

43
00:03:40,230 --> 00:03:44,460
Once again this is called My read write a string.

44
00:03:44,460 --> 00:03:52,250
So this is a read write to string and then I have another one which is read only a string.

45
00:03:52,690 --> 00:04:02,170
And I'm sure you can imagine what happens now if I go ahead and make two of these properties in my file.

46
00:04:02,210 --> 00:04:16,520
Anyway I am I'm going to say my class my object is my class knew that I could go ahead and say my object

47
00:04:16,700 --> 00:04:25,220
got read right becomes hello but if I try the same thing we might read only

48
00:04:27,990 --> 00:04:28,850
look what happens.

49
00:04:28,860 --> 00:04:35,460
It gives me an error saying that hey you cannot set anything to a read only property simply because

50
00:04:35,460 --> 00:04:41,050
the only properties are meant to be only changed as an initialization level.

51
00:04:41,250 --> 00:04:44,350
So for that you cannot change anything.

52
00:04:44,730 --> 00:04:50,120
So because of that behavior we can only set the read only by using an EVA.

53
00:04:50,200 --> 00:04:55,890
And that means using the set to read only a string which is something that we often do when we want

54
00:04:55,890 --> 00:04:58,490
to do some internal calculations.

55
00:04:58,590 --> 00:05:03,160
So more of this will come in in a few minutes and we're talking about eyeballs.

56
00:05:03,180 --> 00:05:09,090
But for now let's say that for most everything you probably want to use or read write which is a part

57
00:05:09,090 --> 00:05:10,630
of the default behavior.

58
00:05:10,980 --> 00:05:16,680
So let's keep that in mind and let's move on to another example which we're going to talk about atomicity

59
00:05:16,680 --> 00:05:18,350
of a variable.

60
00:05:18,590 --> 00:05:23,640
So for doing that I'm actually going to go ahead and start a new project let me copy everything from

61
00:05:23,640 --> 00:05:26,720
here because you're going to need a lot of these things.

62
00:05:26,910 --> 00:05:31,440
And when I go in here and say command line tool are you putting more.

63
00:05:31,460 --> 00:05:39,800
Tomas the object is c and then in this one I'm going to paste everything.

64
00:05:39,880 --> 00:05:44,600
So here on the top forget the default ones if you know what they are.

65
00:05:44,910 --> 00:05:47,150
You could add everything in the same project.

66
00:05:47,150 --> 00:05:50,460
For me I'm trying to have everything in one screen.

67
00:05:50,460 --> 00:05:52,480
That's why I like it this way.

68
00:05:52,680 --> 00:05:55,210
So the laugh then becomes atomic.

69
00:05:55,260 --> 00:05:57,750
One of them becomes none atomic.

70
00:05:57,750 --> 00:06:00,830
And if you remember atomic is the default behavior.

71
00:06:01,020 --> 00:06:08,940
And of course I'm going to change names to atomic string and non atomic string.

72
00:06:09,180 --> 00:06:11,060
So let's see what these two things are.

73
00:06:11,070 --> 00:06:15,930
I'm only going to write two keywords for each of these in the hopes that you know that would kind of

74
00:06:15,930 --> 00:06:18,570
explain it for what's coming up.

75
00:06:18,750 --> 00:06:30,120
Atomic is multithreaded and lock non-atomic is single threaded and unlock.

76
00:06:30,530 --> 00:06:32,310
Let's see what all these things mean.

77
00:06:32,340 --> 00:06:36,810
Thomas It essentially is about the way that something gets access.

78
00:06:36,810 --> 00:06:42,360
Imagine if you have two different threads or three different threads are trying to change a value of

79
00:06:42,360 --> 00:06:42,880
something.

80
00:06:42,900 --> 00:06:47,430
Maybe you have a thread that is you or you are reading you are seeing things and then you have another

81
00:06:47,430 --> 00:06:51,150
thread which is trying to kind of cure back and then read some information.

82
00:06:51,220 --> 00:06:54,230
I you have another thread that you are doing some calculations.

83
00:06:54,240 --> 00:06:58,260
So it's very common to have multiple threads at all times.

84
00:06:58,280 --> 00:07:03,750
So in a situation where all these threads are trying to access the same value it becomes a little bit

85
00:07:03,840 --> 00:07:08,600
unclear of which one is accessing it first which is writing it first.

86
00:07:08,760 --> 00:07:14,970
And when we are trying to read it tonight which of the values we get access to now in a situation where

87
00:07:14,970 --> 00:07:17,160
you have a variable which is atomic.

88
00:07:17,160 --> 00:07:20,990
It means every thread can simultaneously access it.

89
00:07:21,000 --> 00:07:25,880
It means every thread before the access that they will lock its value.

90
00:07:25,980 --> 00:07:33,000
So in the meantime while doing something on it if you try to access not one you see the previous value

91
00:07:33,240 --> 00:07:34,270
which is a good thing.

92
00:07:34,290 --> 00:07:41,380
It means you will get some value back your value will not be needed because that trade is doing something

93
00:07:41,380 --> 00:07:45,810
that is the downside of it is you might not get the correct value.

94
00:07:45,840 --> 00:07:51,840
It might be that you're getting the value right before an operation and you're not seeing what is happening

95
00:07:51,870 --> 00:07:53,550
inside the operation.

96
00:07:53,560 --> 00:07:59,850
Now in a non-atomic value Well what's happening is is only one thread that can access the value at any

97
00:07:59,850 --> 00:08:03,190
given time and it doesn't try to lock it.

98
00:08:03,210 --> 00:08:07,240
It just goes on and it starts changing the values of that viable.

99
00:08:07,380 --> 00:08:11,290
And the downside of it is obviously you might get a near lvalue.

100
00:08:11,490 --> 00:08:13,350
So let's see this in practice.

101
00:08:13,380 --> 00:08:18,340
And I should warn you that some of the gold I'm going to write in here is a little bit at last for us.

102
00:08:18,370 --> 00:08:23,600
We're going to see these in in a few sections when we talk about trading sessions.

103
00:08:23,610 --> 00:08:28,440
But for now we kind of need to just just see them as a demonstration.

104
00:08:28,440 --> 00:08:31,370
Don't worry about specific ways that they work.

105
00:08:31,440 --> 00:08:38,490
So here I have my object and I have my object dot atomic string and I'm going write most of them in

106
00:08:38,490 --> 00:08:45,030
one line saying is my non atomic a string.

107
00:08:45,030 --> 00:08:48,740
And they both have a let's say a default value.

108
00:08:48,960 --> 00:08:54,680
So by now we have an object that both of these things are set to something and we know if we print these

109
00:08:54,820 --> 00:08:57,270
are we're going to see essentially the same thing.

110
00:08:57,390 --> 00:09:02,360
So this next thing is going to be quite new for us and that is how to start a new thread.

111
00:09:02,400 --> 00:09:08,340
So solving it two ideas usually are an operation that happens by something else you know when you access

112
00:09:08,340 --> 00:09:14,010
to a network or you might want to manually you know write thread to update your you I but here when

113
00:09:14,100 --> 00:09:22,630
I started that word on my own I'm going to say dispatch in a dispatch from say dispatch a sink dispatch

114
00:09:22,680 --> 00:09:25,500
a sink and the one I want to use is this.

115
00:09:25,520 --> 00:09:36,420
CH This gets main gets global Q And then for the identifier I want to use that dispatch you are priority

116
00:09:36,650 --> 00:09:38,540
bygones.

117
00:09:39,370 --> 00:09:40,280
No flags.

118
00:09:40,360 --> 00:09:42,400
Here is the body of the code.

119
00:09:42,430 --> 00:09:49,420
So this piece of code essentially is going and starting in thread for us and then I start this new thread

120
00:09:49,450 --> 00:09:50,460
I'm going to do this.

121
00:09:50,560 --> 00:09:53,220
I'm going to save both of these values.

122
00:09:53,260 --> 00:09:57,790
Let's give them something else let's call it the second value.

123
00:09:58,090 --> 00:10:00,500
So that is Sanken value.

124
00:10:00,880 --> 00:10:07,930
And then I'm going to go ahead I start another thread in here and say both of them they get it here

125
00:10:07,930 --> 00:10:08,710
at the rally.

126
00:10:08,920 --> 00:10:10,140
So what's happening.

127
00:10:10,150 --> 00:10:14,420
We have a default value that is our clients value.

128
00:10:14,440 --> 00:10:21,430
Two other threads are accessing these values and changing them to other things and they're all happening

129
00:10:21,430 --> 00:10:24,410
simultaneously at the background level.

130
00:10:24,670 --> 00:10:30,640
So the very important question becomes so what is the value in either of these two right now.

131
00:10:30,820 --> 00:10:38,850
So if I go in here and I say a slide and I would say are atomic is.

132
00:10:39,880 --> 00:10:43,720
I would say my object not atomic is string.

133
00:10:44,500 --> 00:10:51,170
And I would copy that and say non atomic is not atomic a string.

134
00:10:51,250 --> 00:10:54,220
We should see what's there is not sought here.

135
00:10:54,310 --> 00:10:58,760
If I run this it shows up.

136
00:10:58,780 --> 00:11:03,440
Now here we see that atomic kids are still defiant.

137
00:11:03,760 --> 00:11:07,080
So atomic is reading the value that was there.

138
00:11:07,080 --> 00:11:10,240
Those other two threads haven't managed to change it.

139
00:11:10,310 --> 00:11:13,930
Non-atomic is the second value.

140
00:11:14,050 --> 00:11:19,110
So if I go ahead and say well let's go to one of these threads and change their priority.

141
00:11:19,250 --> 00:11:23,130
You say high priority.

142
00:11:23,410 --> 00:11:31,020
I run this one now my non atomic value reflects the most recent update.

143
00:11:31,050 --> 00:11:33,710
It is as you know a single threaded.

144
00:11:33,750 --> 00:11:35,160
It's not locked.

145
00:11:35,160 --> 00:11:41,010
It goes and says well finished this thread finished that thread finished that thread and then give me

146
00:11:41,010 --> 00:11:41,860
the value.

147
00:11:42,020 --> 00:11:47,430
One of my atomic s thing says well I'm just trying to get you the result and the result I can find the

148
00:11:47,430 --> 00:11:50,070
right of way is whatever it was there.

149
00:11:50,070 --> 00:11:52,320
I'm not going to worry about those other threats.

150
00:11:52,470 --> 00:11:57,690
So there is some advantages to using either of the two and the situation will come for you when you

151
00:11:57,690 --> 00:12:00,220
know that you have to use non-atomic.

152
00:12:00,240 --> 00:12:06,900
But for most everything you can use atomic which is the default behavior in X code anyway.

153
00:12:07,080 --> 00:12:11,450
So that was about the atrocities of a value bet.

154
00:12:11,490 --> 00:12:17,850
Now let's move on to another topic and that's another off whether an object is being copied or it is

155
00:12:17,850 --> 00:12:18,930
being assigned.

156
00:12:18,930 --> 00:12:24,330
So we'll see what that means in a Cygan like the last time I'm actually going to copy everything from

157
00:12:24,330 --> 00:12:31,320
here and then I start a new project this new project I'm going to call it to argue copy versus assign

158
00:12:31,710 --> 00:12:34,280
Objective-C of course.

159
00:12:34,890 --> 00:12:40,560
And bear with me as I paced this and I change a lot of stuff.

160
00:12:40,680 --> 00:12:44,300
So off the top I don't have to worry about the atomic part anymore.

161
00:12:44,310 --> 00:12:52,110
I'm going to change one of them to copy quali copied the string and then I'm going to change one of

162
00:12:52,110 --> 00:12:55,760
them to sign and I'm going to call this one.

163
00:12:55,980 --> 00:13:01,400
I signed this thing and then it changed that effect.

164
00:13:01,500 --> 00:13:09,720
And in here I don't have any of those threading and whatnot but I do have is that they both have one

165
00:13:09,720 --> 00:13:17,620
initial value let's call it copy the string is assigned a string.

166
00:13:17,610 --> 00:13:24,030
I don't want them boys to be looking at the same static value I wanted it to be actually inside another

167
00:13:24,030 --> 00:13:24,990
variable.

168
00:13:24,990 --> 00:13:33,370
So I'm going to go ahead and say how I in this mutable string and when I call it a value which is an

169
00:13:33,390 --> 00:13:40,460
S mutable a string string by a string and the other string says default.

170
00:13:40,470 --> 00:13:45,480
So the reason I want it to be inside an estimate of a string is because I want to change that value

171
00:13:45,480 --> 00:13:46,480
really soon.

172
00:13:46,580 --> 00:13:53,460
So I'm going to say most of these guys they are value so whether they are copied or assigned for that

173
00:13:53,810 --> 00:14:01,770
is copy or assign they are going to be the same value of a value which is on an estimate about a string

174
00:14:02,090 --> 00:14:07,680
for the next piece is actually very easy once there are those assigned to one I'm going to go ahead

175
00:14:07,710 --> 00:14:17,870
and say Well Van has actually had some stuff at hand and some new things.

176
00:14:18,480 --> 00:14:26,240
So as you can all imagine right now the value inside the value is the default space.

177
00:14:26,320 --> 00:14:28,310
And some new things.

178
00:14:28,350 --> 00:14:33,220
Now what happens if we print or copy this thing and assign the string.

179
00:14:33,420 --> 00:14:36,830
So I'm going to say copy it.

180
00:14:37,500 --> 00:14:45,850
Copy the string I signed and signed is going to be signed the string.

181
00:14:46,410 --> 00:14:58,290
Let's run this project I execute that you should see down there my so that copy is a default.

182
00:14:58,390 --> 00:15:03,310
It doesn't have those extra bits of text and a sign is having everything.

183
00:15:03,310 --> 00:15:04,990
So this is what it means.

184
00:15:04,990 --> 00:15:08,650
It means that copy any value but of the type copy.

185
00:15:08,770 --> 00:15:14,440
When ever you assign them whenever you initialize them they make their own copy of the value and they

186
00:15:14,440 --> 00:15:22,430
place it in a newer spot in the memory while a sign essentially keeps a pointer to that part to whatever

187
00:15:22,530 --> 00:15:31,600
was of value in there just so that you know we know a sign is very similar to the page and copy is very

188
00:15:31,600 --> 00:15:36,380
similar if you are strong and that's something we're going to see in the next example.

189
00:15:36,400 --> 00:15:39,310
What is the difference between these two guys.

190
00:15:39,370 --> 00:15:44,920
So to demonstrate the relationship between a strong and Veeck qualifiers I'm actually going to go ahead

191
00:15:44,920 --> 00:15:50,650
and start a new project and this one I'm actually doing it in suites simply because that's something

192
00:15:50,650 --> 00:15:53,120
that we use more often in swift.

193
00:15:53,140 --> 00:15:56,000
I'm going to say are strong.

194
00:15:56,110 --> 00:15:59,550
We are stryfe in here.

195
00:15:59,560 --> 00:16:00,860
Here's what we're going to do.

196
00:16:01,060 --> 00:16:06,360
I won't write an app that has a very basic user commenting relationship.

197
00:16:06,460 --> 00:16:15,070
So here go ahead and say on the very top I have a class called common.

198
00:16:15,340 --> 00:16:17,850
Then you have another one class.

199
00:16:18,000 --> 00:16:19,880
This one is users.

200
00:16:20,170 --> 00:16:28,660
So we have two classes so far they have common and we have usage so for comment I have about our text

201
00:16:29,020 --> 00:16:33,540
which is going to be empty at the beginning so that's it takes the body off the comment.

202
00:16:33,760 --> 00:16:35,690
I also have a use for it.

203
00:16:35,770 --> 00:16:41,430
I have a that I'm going to call it on there and that's going to be a user.

204
00:16:41,920 --> 00:16:45,520
And that's essentially who has written that comment.

205
00:16:45,670 --> 00:16:52,610
Now for a user itself every user has a name which by default is empathy.

206
00:16:52,690 --> 00:16:56,290
And then every user also has a Carman's

207
00:16:58,530 --> 00:17:03,960
Harmons which is going to be our comments of course.

208
00:17:04,020 --> 00:17:08,680
Now you know in real life scenarios this obviously would be an array of comments.

209
00:17:08,690 --> 00:17:14,630
But for now I'm trying to simplify things and I'm assuming one user can comment on what other user and

210
00:17:14,630 --> 00:17:15,320
vice versa.

211
00:17:15,350 --> 00:17:18,680
Nobody can comment on multiple different people.

212
00:17:18,860 --> 00:17:24,530
So that's that and of course I need to have an initialiser in it here.

213
00:17:24,560 --> 00:17:27,500
Can to say in name.

214
00:17:27,740 --> 00:17:33,920
And I think that's pretty much all I would need because come on they have to just start a new one.

215
00:17:34,070 --> 00:17:42,080
So that's easy I'm going to go ahead and say self-taught name becomes input's name and I'm going to

216
00:17:42,080 --> 00:17:48,690
say self-taught Carmens becomes a new comer.

217
00:17:49,520 --> 00:17:56,000
So so far we have two classes that each of them deals with something one of them deals with having writing

218
00:17:56,000 --> 00:17:56,540
comments.

219
00:17:56,540 --> 00:18:00,070
The other one deals with holding onto all of our users.

220
00:18:00,230 --> 00:18:08,840
Now the tricky thing here is the balls have a variable of each others type within them and that's somehow

221
00:18:08,840 --> 00:18:10,090
a common situation.

222
00:18:10,100 --> 00:18:12,140
You know you're right you're a staff innovator.

223
00:18:12,140 --> 00:18:19,190
They have data relationship between them and we have to find a way to make sure that our retained count

224
00:18:19,250 --> 00:18:22,550
doesn't go up beyond what's meant to be.

225
00:18:22,550 --> 00:18:25,650
So here's how they're going to test this whole thing.

226
00:18:25,670 --> 00:18:34,470
I'm going to go ahead and say let's make one use of let's say my user that's going to be a user of.

227
00:18:34,890 --> 00:18:38,220
And the only thing I have to give it is John.

228
00:18:38,310 --> 00:18:38,590
Right.

229
00:18:38,600 --> 00:18:40,980
So I have a user with the name John.

230
00:18:41,150 --> 00:18:48,250
And then I'm going to go ahead and preens how many retain count I have for this user.

231
00:18:48,290 --> 00:18:51,760
So I'm going to go ahead and save print in my print.

232
00:18:51,770 --> 00:18:58,280
I'm going to go ahead and say our users count is what is it.

233
00:18:58,290 --> 00:19:03,890
Is this something that you know is perhaps new for you and that is get retain count.

234
00:19:03,890 --> 00:19:08,770
So I'm going to say see I get to retain count.

235
00:19:08,900 --> 00:19:10,600
And what I want to get the count of.

236
00:19:10,610 --> 00:19:12,920
I want to get the count of discard.

237
00:19:13,440 --> 00:19:18,300
So what it does it gets how many copies of these are in the memory.

238
00:19:18,470 --> 00:19:23,960
And by default this should be torn out because it should be one for the actual valuable and one for

239
00:19:23,960 --> 00:19:24,950
the hour.

240
00:19:25,130 --> 00:19:26,210
So let's run this

241
00:19:29,160 --> 00:19:33,050
and once or up front it says the user's account is true.

242
00:19:33,120 --> 00:19:37,110
So that's so far perfectly working the way we expected it.

243
00:19:37,110 --> 00:19:48,660
Now what happens when I do this when I say my use of dot comments which is that valuable in here.

244
00:19:49,050 --> 00:19:56,320
Dot on there which is this you in here becomes my user.

245
00:19:56,670 --> 00:20:04,830
So sure I think you could have a lot of situations where a user has commented on themselves or tool

246
00:20:04,920 --> 00:20:11,700
users or to use as they have commented on each other and each of them is being used both as the guy

247
00:20:11,700 --> 00:20:15,710
who owns the comment as well as the guy who writes that comment.

248
00:20:15,720 --> 00:20:20,360
So now my user comment owner has become my user.

249
00:20:20,580 --> 00:20:24,040
And now let's go ahead and reprint this user accounts.

250
00:20:24,060 --> 00:20:26,340
Now is

251
00:20:29,480 --> 00:20:30,060
trick.

252
00:20:30,170 --> 00:20:31,640
And here's the problem.

253
00:20:31,730 --> 00:20:39,800
The problem is that the next time we were trying to point to this user through this comment on our not

254
00:20:39,800 --> 00:20:46,490
only we pointed out that but also he copied it in a newer space in our memory which is really not a

255
00:20:46,490 --> 00:20:47,060
good thing.

256
00:20:47,060 --> 00:20:54,440
We ended up having more than one copy of my user and that's being assigned for only this one.

257
00:20:54,650 --> 00:20:59,180
So to remedy that I'm going to go ahead and say that it's a very simple fix.

258
00:20:59,360 --> 00:21:06,200
This on average which is only going to be a point there has to be a weak link.

259
00:21:06,350 --> 00:21:16,620
If it is a weakling it's means like a sign don't copy it means do not copy the value.

260
00:21:16,760 --> 00:21:26,520
So let's go ahead and say it and now both counts are still too simply because here be are setting that

261
00:21:26,520 --> 00:21:28,700
we are not adding another account

262
00:21:33,060 --> 00:21:39,140
and finally in this lesson we're going to talk about uveitis or directly accessing valuables.

263
00:21:39,150 --> 00:21:40,550
Let's see what they are.

264
00:21:40,710 --> 00:21:48,150
I'm going to start a new project in export objective c and this is going to be.

265
00:21:48,640 --> 00:21:55,880
It has our eyes objective see.

266
00:21:56,250 --> 00:21:58,210
Let's see what they mean.

267
00:21:58,290 --> 00:22:11,430
Imagine we have a class up here I have an interface interface Let's call this a user class and as object

268
00:22:11,610 --> 00:22:15,120
as you know we don't know if you need anything else for it.

269
00:22:15,130 --> 00:22:19,880
I also have implementation and that's going to be a user.

270
00:22:20,310 --> 00:22:25,650
And then I have some functions in here and I'm going to call this one some function doesn't matter what

271
00:22:25,650 --> 00:22:28,940
it does some function.

272
00:22:29,010 --> 00:22:35,810
Now if you remember whenever you had a situation like this and you had a property that property and

273
00:22:35,810 --> 00:22:43,320
that property was friends and as a string to some property we could do two different things when we

274
00:22:43,320 --> 00:22:45,330
wanted to access that property.

275
00:22:45,360 --> 00:22:55,530
You could either say on this or some property that becomes hello and all of it would say self that some

276
00:22:55,530 --> 00:22:58,150
property and that becomes held.

277
00:22:58,200 --> 00:23:00,580
So what's the difference between these two.

278
00:23:00,600 --> 00:23:04,850
I'm actually going to write it V-twin here within the actual body of it.

279
00:23:05,030 --> 00:23:10,570
This here says directly accessing the value of that.

280
00:23:11,370 --> 00:23:17,910
And this one says accessing very well Rudy said.

281
00:23:18,240 --> 00:23:21,070
So what is the difference between these two things.

282
00:23:21,150 --> 00:23:27,570
When you declare a property using the property in Objective-C it automatically does something that we

283
00:23:27,570 --> 00:23:36,230
call synthesize and what synthesize does is essentially sets the two variables sit there and get there.

284
00:23:36,390 --> 00:23:43,800
So what you don't know is by default this thing now has something called Set some property is actually

285
00:23:43,800 --> 00:23:49,040
a function called void set.

286
00:23:49,110 --> 00:23:54,890
Some property is already being built which receives a property and sets that.

287
00:23:54,930 --> 00:24:01,050
And if you use this dot operation you're essentially accessing that method.

288
00:24:01,050 --> 00:24:06,460
If you use the underscore one you access the variable directly.

289
00:24:06,630 --> 00:24:09,930
So in most cases that doesn't really make a difference for you.

290
00:24:09,930 --> 00:24:15,680
You could use either or simply because you don't care about what is within the body of the set.

291
00:24:15,760 --> 00:24:19,010
But if you want it you could manually do the sender.

292
00:24:19,020 --> 00:24:22,070
So go ahead add in your value.

293
00:24:22,480 --> 00:24:30,300
I'm going to call it manual property for my money or property I'm going to write a boast that said there

294
00:24:30,390 --> 00:24:35,550
and they get there myself I'm going to go ahead and say void them.

295
00:24:35,580 --> 00:24:44,270
And here is the set mining all property to something and then I'm going to go ahead and say and that's

296
00:24:44,270 --> 00:24:52,050
a strange because it is of the type of string right manual property return.

297
00:24:52,260 --> 00:24:56,970
What should it return it should return the cell the manual property.

298
00:24:56,970 --> 00:25:01,360
So here is how I have essentially written Boerse of these manuals.

299
00:25:01,410 --> 00:25:07,770
And in this set we should receive an input value that you can call it nine you want to recalculate new

300
00:25:07,770 --> 00:25:14,790
value and then it of course has to have the same self that non-null property has to become new value

301
00:25:15,240 --> 00:25:16,010
or.

302
00:25:16,050 --> 00:25:22,350
And this is the only time that this happens or you might not want to do that or you might want to do

303
00:25:22,710 --> 00:25:31,140
something before you sign for whatever reason you might have a situation that you need to do something

304
00:25:31,140 --> 00:25:32,360
before you sign it.

305
00:25:32,490 --> 00:25:36,060
So that's essentially how these two will be different.

306
00:25:36,210 --> 00:25:38,250
You could get used to using either of them.

307
00:25:38,250 --> 00:25:44,880
I personally for the most part I use this system accessing through the other simply because of this

308
00:25:44,880 --> 00:25:53,100
very fact if I decide to change something in there I can easily go ahead and do it and if I had so many

309
00:25:53,100 --> 00:25:58,490
of these being applied like that I can always just change something in the solder.

310
00:25:58,680 --> 00:26:02,140
And they've all will be affected by it.

311
00:26:02,280 --> 00:26:08,760
Well if I use the IRA if I use the direct taxes then I have to go to each of them and manually change

312
00:26:08,760 --> 00:26:10,200
that value.

313
00:26:10,200 --> 00:26:17,520
So that's about that are AMANDO a quick recap of everything that we did because it's kind of a lot of

314
00:26:17,520 --> 00:26:19,480
stuff in this one lesson.

315
00:26:19,530 --> 00:26:27,460
So here we did these things we talked about atomic on non-atomic.

316
00:26:27,800 --> 00:26:34,100
If you remember this was a single trial that might be nil.

317
00:26:34,130 --> 00:26:43,470
This one was multithread that never Nan might be wrong though it might show you the wrong value.

318
00:26:43,590 --> 00:26:55,570
We talked about a sign on copy and we said in the sign of point a location in memory coffee or Surely

319
00:26:55,840 --> 00:27:04,300
I typed that the wrong points copy essentially copies information for itself.

320
00:27:04,480 --> 00:27:09,510
That's about that which is a weak link.

321
00:27:09,580 --> 00:27:25,990
Existing as long as someone has connections to it are the strong is a strong link living for as long

322
00:27:26,080 --> 00:27:28,740
as the cycle lives.

323
00:27:28,900 --> 00:27:35,170
These warnings aren't exactly right that for instance would be kids essentially saying maintain it as

324
00:27:35,170 --> 00:27:38,970
long as someone else has a strong relationship to it.

325
00:27:38,980 --> 00:27:43,160
What I'm trying to I don't know in my own way I'm trying to simplify things a little bit.

326
00:27:43,330 --> 00:27:47,300
So that's about that different qualifiers for properties.

327
00:27:47,320 --> 00:27:50,410
For the most part we stick to strong.

328
00:27:50,650 --> 00:27:54,360
And if you're so go read the right of your so go for it.

329
00:27:54,490 --> 00:27:58,890
But there might be situations that you decide to change any of these.

330
00:27:58,930 --> 00:28:03,190
Like I said you can live with the default values for now and when the time comes.

331
00:28:03,190 --> 00:28:10,060
Hopefully by then you will know yourself if you have a change of those with that in mind on this very

332
00:28:10,060 --> 00:28:13,530
long lesson finished let's move on to our next lesson.
