And let's go ahead and get started.
Let's go ahead and get started.
Okay, let's go and get started. I started recording.
Live transcripts I think should be enabled. If not, let me know.
After the exam is going to be. So, mid term so mid term is on Friday.
So,
Okay that was interesting sound.
Okay.
So, uh so yeah so and it's.
so.
Okay.
I'll be available for the office hours after I hit that back on the classroom.
Because actually, I'd rather have you all say hi and say hey what's going on, rather not.
the volunteer side.
So I'm going to. So the.
So I'm going to post basically once the exams are graded then onto the interviews because there's a big sense for me to talk to you until the grades are done.
So
there'll be an Excel spreadsheet on teams where you'll be able to select which one.
Most of the things I'll select will be random. But if I have any concerns about a buddy's exam I will specifically talk to you.
So
sorry I I got behind on that and
I'll see what I can do about a two grading but no promises on that
is their coding.
So was there a coating on the assignments.
Technically, yes, but not much.
So writing code ice is something that is
easy to do, once you understand code reading code is actually much harder.
So, so right basically I will
class.
Okay, A
question questions.
I haven't finished making it yet so I'm not quite sure, but
it should be quite doable in the time but not if you're spending time.
So, one thing to note that this class with the way things are set up you'll notice on the assignments.
It's not that Google.
It's. There's some stuff you can look up. But mostly, you have to understand the code as it is.
And you can't you know you can't just look up you know oh explained to me this program you know you have to have the skills to go through it.
The questions.
Do you get bonus marks for volunteering. No, you're not get both a smartphone chain but if you do sign up to talk to me about your test, I may be able to find extra marks, maybe pens.
The question was similar to material what Yes, exactly. It's based on assignment one into the exam will be fair is not going to have your surprises but it's not going to be exactly the same questions.
The way I construct these exams, is by going through the assignments question by question seeing what the concept is for each one, and then asking about the same concepts.
So, if you understand the concepts behind each of the questions. It's fine if you just found the answers by brute force.
Yeah, not not that then that will work so well.
Yeah, you gotta look to you it's open note, open internet you can look up whatever you want on you know so during the test.
Notice the open book open note, open book.
So, if you are trying to remember how does this particular syntax work or so like that yeah you could look it up, but
a 80 minutes. Yeah, it's see any minutes.
Okay, we're going to repeat the questions now so let's move on to talking about the solutions.
Because I posted assignment to solutions.
It's right here for you to look at
bigger.
So, so explain how to add the image for Wikipedia to a list of the underneath boxer.
This one was really simple you just add it to the dictionary.
So I'm going to go through these relatively quickly. I am happy to discuss any of these answers and walk through the code. In fact, I have, you know, my, my Mac is sitting here ready to go.
But I'm not going to go there unless there's some specific question.
So where was I going to get my window. Okay so, so, so this one should have been pretty easy that was literally just making sure you.
Okay.
Ok so now I can refer back to the code, which is still to make.
There we go.
So, up for question one. All you had to do was change this, and enter the dictionary.
You know, we already started. Remember that we've already started Android in those not there, tutorial six is Android. So,
where are the solutions posted for assignment one side what is
right there.
There's no tutorial for this week.
There's no two trophies notice, nothing is scheduled on here for this week, the tutorial is scheduled for March 9, and which is next week.
Anyway, so.
So what we're talking about here now so what is easy you literally just add it to this dictionary online, big deal.
Will the solution to the questions portions of the tutorials be posted know, they will not the relevant portions are included in the assignments.
If there are any questions in the tutorials that you don't understand.
You should ask. Now remember, the reason why I don't post the answers is very simple.
It's not about memorizing, it's about understanding if those questions are not clear. That means you haven't learned the code.
And I test the your understanding of the code through the assignments.
So, let's go. Number two. So what is the name of what what name is added to the menu if he manually enter a URL and select remember image.
So the last component of the URLs path is added to that as a menu item.
So what this is talking about is, this is talking, you know, so when you go through this code you go What does.
The code is in line here the app we specify the function here rather than a separate name functions closer. So we split the string of the image based on slashes. So now we have an array of ups of the parts but you know there and then the new name is basically
the last element of that array.
So it's the last portion, after the last slash.
And so we append that to.
Yeah, we are the image a we append that to our list of names and you know so that's that's that's all it is so I'm looking for you to explain these two lines of code,
then number three.
If your PC is very sorry this is a side thing I got a question about doing tutorials six, and Android simulator being very slow Yes, it's a pig.
Yeah, this is not related to site we can talk about later.
Use an Android device. If you don't want to run the simulator. If your computer is too slow, plug it in and compile it deploy to it.
But yeah, let's focus on the assignment now please.
So we're talking now.
If there is an image in an in line 63 and get an image, when is image displayed during normal operation why. So let's look at line 63.
Here's line 63.
This returns.
You know, images image name, unless I'm so I thought we had this question, question mark. And then this. So what that means is, if, if the images image name is no, then we return this URL.
I don't know if any of you loaded this URL.
But there's a little bit of an Easter egg there.
Well, you can go load it curious.
By the way that picture is is yellow so I'll bring it up here.
Yes, this is my picture from my yearbook my high school yearbook. So,
so, so this is, this is kind of, it's not it's, it's the is no coalescing operator is what it's called but the idea is if this is no, it is your turn to an if statement.
If this is no then it does not know you get the return this value otherwise we return this time.
So the question here is asking when is images image name.
Was I not know we're talking swift so it's nil. So annoying that they have all these different names for the same thing. So let's images is the dictionary here.
So it's when we look up something in here.
And it's not there.
So the question is, when can that happen.
So, we need to have something that there's a key in there that doesn't exist. Now, we start off with a valid key here, because we assign a hearing or kittens is right here.
And then we only the only places we change the value of it is here.
And this is the only place to be assigned to the image.
Other than this.
And when we do this, we're calling get image of ass.
And that does a look up here. And you'll note that this is where do we ever giving an S, you know, where are these from, you know, image names in, you know, you know, as in these are all from image names image names.
Is
this you know the keys in the images dictionary. So, It's impossible with the way the code is currently run. The only way you could do it is if you're initially assigned it differently but as long as this image, this value is correct and the rest of them,
you know, you'll change the rest of the code, it's always gonna be a valid thing, so you'll never see this image.
Yeah so yeah so Exactly, yeah. Never.
Well, no. So, if you add a button, then find a key that isn't exactly different Yes, you can for you can change this program in various way in how to your to make that appear.
But no, that is not the question that was not what was asked what assets, there is an image on your with, when is this image displayed during normal program operation.
And the answer is never.
So I was looking for as the answer is never if you explain for this question, how you could change the program to make this thing show up.
If that's part of an explanation for why it never can happen fine but this is not asking you to change the code, it's asking you to explain how the program works.
So, so that's so this is the answer. So this is very important in my, you know the way I do my questions, part of what I am testing is reading comprehension.
You know, no this is not an English class but you're in order to do technical work you have to show that you understand the concepts and that in programming is all about precision.
You know computers are very unforgiving.
And part of. And when we communicate with others trying to fit what we have to be able to communicate precisely. So that's, you need to be able to discuss these programs in a precise way.
Yeah.
Yeah, so he said it My answer is it can happen when kittens is misspelled misspelled and get you know, as well. So,
in all program operation, the answer is never.
And you can say that, okay well if you did this and this and this.
That's fine, but to get full credit.
You have to say never.
Yeah.
So,
Yeah, you can get some partial marks will be generous marketing partial marks but you know this this kind of analysis is very important of saying, Can this condition everything so you might say, well,
Should you actually do this.
Actually, this is a great thing to this kind of thing is great to put into your program, because what you're doing here, effectively, this image, what you'd want this image to be is basically be something saying, if you see this image something very bad
has happened.
You know, it's all it's good to put things in to, like, Okay, this code should never be reached.
But I'm going to put this in here because that way I know I messed up my code because of course programs are never perfect, or more poorly programs always change.
And when we change programs we can always introduce bugs. So this is an example of defensive programming. And you note that the design of Swift, with the whole require it.
Having optional types for values that could be nil is really to force you to program defensively, for you to think about values like well that could never happen well, show me, you know, prove it to me.
And, you know, if you don't want to prove to the compiler you can put an exclamation point and say, Nope, just trust me, it'll be fine, and you are taking all the risk of the purple crashing.
But that's up to you so yeah that's what I could have also done is I could have just put an exclamation point here, not would have forcibly unwrapped it.
But then if whoever was no, No, no, then it would blow up
there. I can ask a question quickly, please. Um, so, I just want to make sure.
If you go back to the code real quick. Yep. So about what you were just saying so literally if you just did return images at image name exclamation mark, that's, that's what you could do technica.
Yeah, and the problem would work fine.
And in fact, we can do that right now in the promo credit but if we ever made a bug in our program where we somehow got an invalid image name.
somewhere, then our program would crash.
Okay and then we got here that specific thing where like Swift is asking, give me a default value or telling me Oh, trust me. Exhausted for every time you return something like every single time.
It's whenever it's possible for a value to be nil
versus a valid, you know, bit of data so specifically where this comes up is because this is a dictionary.
And so when you look a string up in the dictionary, it's possible for the spring, you know not to be mapped to a value in the dictionary.
So then if, if you were to say return three the number three, then you wouldn't need a default value.
Yeah, exactly.
Okay.
Yeah, it's only if you're doing some operation that could result in nil.
And it's typically the most common thing is when you're looking up in the dictionary. But if you're, you are. The other thing is like you have an uninitiated value or something like that.
That makes sense. Thanks. So, so, again, Swift is forcing you to program defensively might say why is the compiler being so restrictive I know what I'm doing.
Okay, let's go on. So where are we now we're at
four, if you delete line 28 instead replace line 20 with our mission Eastern European the pro will compile a local it functioning differently, why.
So, question is, we delete line 28
delete this here.
And instead, we just put a line 20 up here so that's outside of this, which is,
which is the so line 20 is, you know, var image names drink division and keep so which is just basically what 28 is. No, we just basically I'm taking this right here and moving this up here.
So
what have we done here. We're saying that image names now is not a state variable.
It's going to be a regular variable.
And it's going to be global.
So, we can put this up here so what how does the program change if you do this.
So it'll work fine.
Except that you can't remember on the image.
And that's
a thought What do you mean, if you click remember image you, so you would have to you have to, when you use remember image, you have to type in a value or copy and paste it from a note like you go to a web browser that can the simulator, go to an image,
copy it, you know, copy the URL and then paste it into the app.
So, you know, that's one way of doing it but yeah you have to have a, you have to have an image, a URL entered in there. But by doing this, you're basically making it so that the state, because this is not a state variable because this then it swift will
optimize the program so that it never updates.
The menu ooZ I mean I know so Oh I see, always say well the state variable. Oh, if you do something else to update the state.
I'm,
it's optimized. I don't think it actually ever changes the menu I don't think you can do anything that you can you get to change the menu.
Okay, it does. Okay, it does refresh everything so I wasn't sure if it refreshes the whole thing.
But
also, so that it doesn't refresh so.
So it's not optimizing away it is rebuilding the entire view and it's looking for image names so if the state of image names changes.
Okay.
Yes, only updates when a state for updates. So yeah, so it's not drawing today right that I might.
I said, right sensibly.
But yes, if another state variable changes.
Yeah.
So, but, again, the idea, the concept I'm looking to get here is when state variables change.
The referencing views are updated.
So, if we take this out of it. But we, you know, but these other ones are there so we do something else with the image, potentially that will cause everything to be drawn into the manual be regenerated and stuff.
But it all depends on the implementation, it might update the menu, it might not. If it remembers the old one, it might keep it.
So, okay so that's for.
So five.
Why does the program have both current image and final amount for employment magnification gesture.
As a program we behave we use final amount knowledge changed. So
the idea here was, it's all about repeated zooms. So if you notice if you get if you just use final amount, and don't use current amount.
What you will see is you just use the on change handler to do things with the final amount. It will zoom, but when you let go and you do a new zoom, it's always proportional to your current zoom gesture, so you can't do repeated zooms.
Did everyone get this.
This is this, I can know can be a little confusing I'm happy to explain it more.
Could you explain number five a little more.
Okay, I get that it resets but nine exactly why.
Okay, let me just look I think it's easier to demonstrate.
Okay so here we have this image here so let me.
Can I do this option.
Oh,
know.
I think I don't know if I have the right key. I can enter in here. I do know.
Nothing is control, control, and then other other areas. Yeah.
No, that's,
it's, it's normally the Option key. but the Option key is being captured by my desktop.
So, Yeah, so I had trouble with it.
If one of y'all can show it that'd be great.
Okay, what can you demonstrate who wants to volunteer. Okay, so go ahead, I'll stop sharing my screen.
So
perfect
case you
have your screen first.
So as the change again. So just first just demonstrate what's working right now. Okay. So, we could do like it zooms out kind of normally what yeah yes well was it while you're doing it is always slow because of, yeah.
Okay, please. Yeah, so now I'm change it so that, so on, get rid of the on ended handler. Just come at that out.
And then instead of current amount just put it final amount.
Okay, And now run that.
I think when you make it like really big tries to try zooming again seats you notice that. That's what happens. So zoom and zoom out. And now try zooming out again.
She always goes back to whatever your zoom factor was just a question is that because I'm the image is really large and since the scale is like relative to the size the image is like jumps by a lot.
Yeah, it's, it's basically, it's the zoom, you're setting the zoom factor to exactly what the magnification gesture is saying the amount should be. Yeah, you're basically one to one mapping between the two.
So we need to create a like a separate skill that is independent of the images good all right well it's just you have to remember the old zoom factor that's what allows you to do repeated zoo.
Okay. That's all right.
Thank you.
Okay, let me share my screen again.
Sure.
Yeah, so that's that's basically what it's saying so let's
not here.
Here we go.
So it doesn't say the origin. So then notice the style of these questions so I'm really looking for is.
I'm looking for you to go through this program, line by line and tell me what the heck is everything do it.
You know why is this code the way it is.
And this code is this code is mostly there because the code all does something.
So, what is it doing.
Ah, you know what, what do each line of lines 50 different no do influence 5253.
So, 5253.
So this, this is actually repeat of like the previous question, the splits it up. This gets the parts, you know, appends it to the know to the,
to the array and then assigns the dictionary to the right value. So, This was kind of given
by verbose there are seven.
If you don't understand six let me know I'm happy to explain parts but I thought actually pretty easy.
So seven is the dragon gesture handler 127 to 137 has both and on changing on exactly the same code in them. What does it code as a chrome function with just one or the other.
Oh, sorry. So, if we said it creates that key is that totally okay since we try to assign a value to the key that doesn't exist it auto created a yeah that's fine for that particular line, but of course there's three other lines so so that that's that
that's fine. Yeah, but I'm going back to that. So, what is going on here.
So this is a part where understanding part of the code is not needed, if you went through this.
127 to 137
on change non end it's like okay this is all doing things. This code is redundant this code does nothing because you already changed it to the right value you don't need do anything when the when the gesture ends because you already set it to the right
value. So, This isn't strictly needed this did all the work.
And the way you could have made sure this is you kept this code in and got rid of this one and saw what happened and did vice versa. And you saw two different things like with, with just the on changed it worked as it did with just the on ended, you did
the dragon and you do the dragon gesture and move it to some other place and nothing happens until you let go and then the image all of a sudden moves.
So okay.
And then eight
does on change x when you stop and then I'm.
that the arm changed your handler runs as the gesture is changing.
And
technically it doesn't know when you let go until you let go so it has to update essentially until that point. So, there might be a slight little bit of difference with the on ended but I couldn't see the difference, because it might miss that last little
update on him but I couldn't see a difference.
Anyway, so how does a program behavior change when you replace line 90 with the on tap gesture here.
This messes up the long press gesture.
single clicking the image causes the initial empty.
So, I have a question. Yes.
So in my case, when I like after I replace my 90 with this, I went and whenever I doubled up, it doesn't zoom anymore, instead rotates the image.
Yeah.
I said,
Oh, the zoom in doesn't work as well, is that the zoomed in work.
Yeah, resuming was double clicking right. Yeah, that didn't seem to me.
Well, so, so, so, oh yeah I did I not.
Oh, I forgot to my sentence, I forgot to finish my solution there.
Fix my solutions. I stopped in the middle there. So what's How is it yeah so I will, I will expand the answer. Yeah. The point of this one was online 90.
So let's look at these what's happening here so we've got all these gestures here. You know, we've got this, you know, dragging gesture and magnifying gesture.
This on long press gesture on top gesture the two in one. So let's saying if we replace this one with count three. Yes, there's no long press because we eliminated the long press handler.
That's kind of the easy part of the answer because we got rid of it. The question is, why doesn't triple click, so triple click works in single click, works.
But, double click, does it.
Why do you think that happens.
He thought,
Oh Is it because of triple click would be like one and then double click okay I don't know about it. Okay, I kind of get I don't know how to explain it.
Yeah.
Does it, I forgot does the triple click, we check this.
I can test this one.
So let's test this so
I'm on.
Okay, there we go. So we'll take this to be.
okay
okay we're good here.
Let's run this.
Then let's see what happens.
Okay, so that's all working.
So now, if I do a single tap it rotates.
That's good. If I do a double click it does a rotate
the double click it just doesn't rotate, and if I do a 123.
Then it resets.
So,
So, so triple click does work and
single click works. But, double click is broken.
Double click actually seems like it's so, so the way I interpret this is that it's waiting for the double is basically waiting for the triple click, and since the triple click didn't happen.
It then thinks it was a single click.
But it doesn't do the.
So, so I don't see this as I, personally, this code should work.
Personally, this code should work. I think, because if you allow for arbitrary accounts, if you allow for triplicate if you allow for a single click. It should allow for double clicking or double tapping.
But it doesn't
show up.
So that's you oh yeah I know you had to test this, it's, it might be a swift UI bug. I don't think it's a swift UI bug, it's probably more fundamental, I don't know.
In my case with your dog.
But yeah, this is a basic thing to understand when doing any sort of development with complex frameworks.
You're going to get situations where you like that should work. I did everything right.
And it doesn't work, basically. Yeah, but I certainly they've tested it for double clicks.
And they tested it for single clicks, you know, single tops, double taps, that all works great.
Nobody does triple taps, if not a thing.
So you're doing an interface pattern.
That isn't what you normally would do. And so, they, you know, it didn't build for it so.
So I think, I think it's just a bug, it's a bug because no one does triple clicks. But again, if I allow account, have one or two it seems like I should build out five, you know, a top account of five.
why can't it count.
But clearly, it can't.
So,
anyway, annoying, but.
code is mostly debugged, you can count on code to be to work for use cases, it has been tested on.
If you are using code for a use case that it has not been well tested on, you should expect bugs, back to life.
Could you use simultaneously with to create a new gesture to fix it.
Perhaps I haven't tried, but again, why in the world are you using triple tap as an interface element.
Yeah, you can't get triple it but why are you doing triple tap that just is a.
It makes it easy, because you want to maybe because it's a game, you know, maybe you have some mechanism want to do and that's right but then you're probably manually recognizing the gestures yourself
when typing a new URL with a sink, when is a sink image updated. Does it try loading the URL as you type or does it wait until the URLs really entered it updates as you type, and you know this because you, because you know, your customers differently
basically you know just like as you type changes state variable to keep trying to update. And that's why we see the progress bar keeps started spinning until you type in the full URL and then it pops in like that.
And then, so I can explain this more fair ask questions.
10, how could you change the program so that the double click zoom command only zooms in three times. And, and on the fourth it goes back to the application of one knows zoom.
People had some difficulties.
Literally three clicks you know if you throw zoom three times, you get up any of you, it's doubling each time so you get eight. So, if the current zoom is eight or larger set it to one.
Otherwise, it's there.
So that's.
You did less than five less than four.
Oh yeah.
Is it correct if you're the if statement without the else.
A.
So, the standard magnification is just one.
That's mean it's like the, the email that the default zoom.
I'd have to look at the code like if cell phone amounts less than equal before then.
Yeah, that's what so so I'm Kareem the with your code you don't actually get it back down to one.
Yeah, it doesn't matter what it is but but but creating your solution. You never set it to one.
If you, if you did 16 verses eight or something.
Like, that's fine. But the big thing is it should, you should do the reset.
Okay.
So, yeah, so that that. Yeah.
Because there's there's some ambiguity and how its interpreted
up how it does. But again, this is such simple code there's lots of different ways to write it. So, how does the progress behavior change if you have lines at 6894483.
So, at six, and 89.
Just before 83. So what this is doing here is this is fixing a bug.
This is fixing a bug, because you'll notice we have the position here, the order in which you do these operations matters.
So what this is saying is, move it to the correct position, then scale it, and then rotate it.
And that's kind of weird because that means that, like if you move the image to some other location, and then you rotate it, I can just, I can show you here.
So let's see which way am I, which version is this year now, it's fine, like here.
This one's fixed.
So rotates in his position.
But now, in the original code.
This line.
Those two lines are after.
They're a little fight different order but basically the thing is you have all the monitoring the images and then you know the gestures. This is a better organization.
So we do this.
So now, if I have this over here and I click it
rotates around the center of the screen.
Yeah, and then it gets all kind of.
Yeah, there's all kinds of weird.
Dragons like really messed up.
So, what I was looking for you to do here is realize that if you know the order of these things matters. Put this back up here.
And then fix the code.
Now you'll notice here, how we do this, and it rotates in as you're expected to.
I still got my
that.
very smart.
It is a weird thing it doesn't like now zooms in on wherever you top.
Oh wait, oh yeah it was it yeah the zoom factor.
Yeah.
Where's.
Yeah. Similar way you expect.
Oh, that's weird I think there's still some bugs in there.
Anyway, Ah.
Any other questions.
Well, side, it sounds like you're basically on the right track.
But any further questions about the assignment.
We otherwise.
Make sure you understand the solutions and again the concepts here that I'm asking that like for example, for question one I'm asking about okay here's, you know, How do dictionaries work.
Do you understand dictionaries. Do you understand that what this program is using the dictionary for.
And then for question to you know what you know what, what is it, what is added to the menu API URL. Why, so
go through each question like what am I, what do you expect it to know for each of these questions what knowledge, do you have to have in order to answer these questions properly.
If you step back and go through, like what I didn't really understand that question or what it's talking about, I don't really understand the answer you go like, okay, there's something that you should be studying.
To do that for the first two assignments, and you should be good for the midterm.
You should understand geometry reader because we do use it.
It's kind of part of this. So, but but but get geometry reader, so geometry reader, just returns of you, that's the same as a containing view, it just gives you information on it.
That's all G is so you can know it sighs and things. It's really a geometry leader.
I've already asked I haven't finished making it the exam so I don't know probably be around 20
relative, so it's not based on content you it's wherever you place the view it's like you have me This is a view, whatever this view is you put a gr to read or inside of it, it doesn't change the geometry of the including view, it's basically exactly
the same.
It's just this is an overlay view on top of it. That just tells you information about it.
The questions are like so so it's just that information on it, and geometry reader gives you lots of information about it, but we're just looked at the size and with
all questions.
Yes, it's short answer. So I'm gonna be short answer questions.
I might give you some little fragments of code saying what the heck is happening in this code
will be any other way to access those like sighs.
what are you asking sod I don't quite
any other way to. Oh without geometry or can you know, you really can't in in Swift UI, you can make assumptions about the size but they'll be wrong because it could be a different size devices.
So geometry is general way you find the size of view. And remember, the views are kind of like, you have this big view and then you like someone else took part of it.
So you have this remaining piece. And then inside of it I got this piece. So,
uh, Steven, Stephen.
Go back and you're asking me about the last question, go back and review what I just demonstrated I can show it afterwards when I stopped the lecture but, um, yeah.
It's a is progress you are loading screen, it's, it's up. Yeah, it's a standard view that just has a spinning circle in it.
Yes.
mean.
Try putting again, these questions about what these are, you can put them into a program and see what they do, or look them up and that's kind of what I'm explaining is like, what does that do.
You should be able to see what it does.
And I will stop here and I'll stick around if people have further questions, and I will post assignment one grades.