Let's go ahead and stop recording.
Okay.
Good. Good morning everyone still morning just barely.
So the plan. So the plan for today is, first off, we're going to where to spend the first part of this class I'm going to lecture and talk about some concepts and demos some stuff.
And then the second half of the class, you're going to spend time on tutorial one.
And so, if you're trying to get caught up, just, yeah.
Yeah, so.
So the latest please share my screen and that will kind of make it a little easier advanced portion of screen share.
Okay, so go away.
So, if you look at the wiki.
You'll find there now there is a, you know, you go here, the main page. If you go down here there's tutorial one. This is the material for tutorial one.
So the idea of the tutorials is these are things you're going to work on in class. So we have two hours twice a week and the idea is during this time, you'll have time to work on this and we will.
I'll have time, you know, to go through. And basically, you'll be able to get credit, with the TA, or me to
to um basically to show that you got it working so we're not trying to see whether you understand everything. We're trying to see, have you have you gotten things running and are kind of messing with the code and interacting with it and stuff.
I test for understanding when you do the assignments.
But this is basically interaction time now. If you don't do the tutorial here during class. You still have time to do it but the idea is you have to do it by the following Wednesday.
and what you need to do is is basically come to our office hours. And so I'll be. So, the office hours for one is 330 to 530 I, on Tuesday. I've decided whether my office hours will be Monday or Tuesday I need to think a little bit more about that perhaps
on Monday. But the idea is you can come with meet with us, and we can go through it. It's also potentially possible to do written answers, but I don't really want to do that, I really would prefer us to at least see you and, you know, see what you've
got going. Now, I'm going to, when you're working on tutorials, I'm going to divide up.
I'm going to open up breakout rooms.
And you all can go to the breakout rooms how you see fit. I'm not.
Or you can stay in the main room but the idea is that there's all these little spaces for you to work in. And you so you don't have to deal with a big crowd, but you can potentially interact with a few other people.
I'm happy to start right, today I'm just going to like leave it open, but I want later on I want to start assigning people to two things so that, so that you can you know get to know each other in the class.
This isn't that big of a class.
And I think you will learn a lot by seeing how other people do things. So if you don't want to be too social, that's okay, but
I find that you can save a lot of time with this sort of stuff by just saying, Oh, that's all you do. And moving on.
But if you are having problems that we can also rain saying where you can just turn in written answer but really the idea for the tutorials, it's really not about.
Yeah, and it's, are you getting things working and kind of messing with the code or things working as opposed to, you have a deeper understanding.
Yeah, so I want to show them dirt you want to show them during class or you show them during office hours.
Okay.
Come on.
So, um, so I think what we'll try this out and if it doesn't work, so in other classes I've done tutorials for many years in various forms of this. That's why things are kind of weird here I have my, my zoom controls are all here.
I know, put them here at the bottom. Sorry arranging my windows so as to avoid big blank spaces. When screen sharing and go here. Okay, that's better.
And
so, so that's how we're going to run think so but for now just relax, we're going to show you some stuff up and then we'll do things.
So
you'll see it's just basically looking over your shoulder you can share my screen and I can see what's going on.
Cuz it's all can help. Repeat where the pages but it's it's on bright space the link to it, otherwise you can see the link here. It's from if you search for so much you know until sociology is wiki.
She'll find it.
If you're not on your Mac maybe you can do so.
Anyway, so what you're gonna be doing the tutorial today is something really stupidly simple from one perspective, and not so simple from another. And the idea is is kind of around this little app that's going to have the square and you're going to type
in the size of the square and it will dynamically change the size on screen.
And it's all of this much code with, you know, comments, so very much going on here it seems but actually there's a lot going on and that's part of what I want to talk about.
So, the thing to keep in mind when we're programming in Swift and swift UI on iOS is that things are the same and things are not the same. So when I say things are the same.
So I've got a simple, I made a command line Xcode project.
Just to show you what things look like Can you all see the text here.
Yeah, we can also.
Okay, great. So, this text. So, this program here. You know, This is a, I will run it for you.
First off, but you know, I just fixed a bug okay so running here. And your name. Anil Hello nl exciting isn't it. So what do we got here, we've got an important foundation classes which you don't even really need.
We've got a print into your name, we've got this letter S equals read line and then, and then we say saying you know if you know name equals ass print hello otherwise, I don't know who you are.
Let's, let's try running this without any input.
I guess I hope it always returns a string, it's an empty string.
But let's, but this code is simple but not, and the not part is.
Well, first let's look at these go through this line by line. First off, print.
Okay, print, print fi Hope you all know that there was a string in here, as the input.
This is a little interesting.
So, uh, yes. And so, let's. So, Stephen you're getting x over the years, Nick is on the weirdness Year
in Swift.
you can have conventional variables.
You can have variables that are immutable you can declare them with the var keyword.
But a lot of times in Swift code, you don't use var you use let.
So,
so.
so this is the key idea that you have to really get in your mind when you're thinking of our versus left.
And that is, if you declare something var.
It means that the variable you're declaring a variable which means you're gonna have a name, and that names value can change. This is your conventional variables that you've seen most the time when you're programming in Java program Python, that's what
you normally see. But in Swift.
We, a lot of times us let and let is more for binding, which means you associate a name, with a value and notice, notice.
so does the Latin for work the same in JavaScript doesn't Swift. No, it does not, because in JavaScript when you say let it is not immutable.
Please don't think so, let i think is more for local variables, but I'm not.
I would have to check that in.
Okay.
Yeah, we'll do so let you know let normally just a local variable here. There is a national locality but there's this notion more of immutability, and that's actually much closer to functional programming. So, if you think about mathematics, mathematics,
it doesn't just change like you can't like in math, x equals x plus one.
Just in general if you feel you're behind.
That's why I record the lectures and give you notes and other things getting back to it because I have other people I need to keep up and so I can't miss a catch, individual people up while we're doing this without losing time for covering material.
So, if you want to ask questions about Did you miss something, go to the discussion channel the lecture channel in disc in discord in teams, you're going to have chats there, I'm not going to see that until I get out of class so that's a great place for
side conversations.
I'm trying to set up more on here so, so this is this now.
So here's, here's a weird thing like just because you see a bar in something in Swift you go like, Oh, I can change the value of that, not necessarily because it may be in the context of a larger structure that is in fact immutable.
Now, Maya, your question.
Yeah, could you provide like an example of this because I'm getting the concept but sometimes it just gets so like hypothetical that I kind of lose what I'm telling you this because you're going to see it very shortly.
Okay.
So this is, this is coming to track, and in particular these ideas, I'm emphasizing this at the beginning because swift UI does this all the time. and in very weird ways.
And so if you don't kind of know what's going on here it's like, whoa. But, but let me show you here what I did in this just this this bog simple program is.
I did this, let s equals read line and then I said, If let name equals ass. This is all kind of like why am I doing a lead here and why am I doing it, if let here, you know, why don't I just do you know why just say if S, you know, if S does not equal.
Let's see does.
All right.
Actually, this might work actually. Let's see if it lets me do that.
Ah, we get in there.
So, value of an optional type string must be unwrapped to about this illicitly click on this value of optional type string question mark must be unwrapped to a value of type string.
Hmm.
So this is the kind of trouble, you're going to get into when things that look kind of syntactically correct and swift. You have to step back and go like, No, you really can't do things that way.
It's not so much a.
This isn't so much a two string kind of thing but that's not what's going on here. What's going on here is that if you look up, read line.
So we go the definition. So, oh that's not quite where I want no, let's go here let's go to show quick help. There we go.
So returns a string from standard input through the end of the current line, or until end to file is reached, declaration read line you know you know boule true whether you.
So if you put a true in here.
Others if you strip the new line from what's Empire saying but then you ever returns a string, question mark.
Whenever you see question mark at the end of a type in Swift. What it means is, is it could be a string, or it could be nil.
So, this is a thing, Java uses no other uses, like things that swift uses nil.
So, no nil, basically the same thing but swift uses now, other languages using all Yes, exactly.
So, but this.
This is. So in most of the time and.
So, So I say in see.
So, in most in so many other languages, when something's returned to me quickly things like strings but also particularly for objects.
You either get the object or you get a identifier that basically means no object or no string like no or nil.
And so, what, so what this is saying, you know, so when you.
So this is, this is the thing. One of the key ideas and swift that's kind of different.
So, yeah, Neil is not the data type of string it's that there is this, if you want to include the, I don't have a value in your type you include you put question mark at the end of it.
So string question mark is a string or nil. But otherwise, if it's just string. It's a string.
And you know that. And so a lot of effort goes basically to me think a lot of time your code you have to basically check. Did I get a no value. No Did I get a real value or did I get something that's actually nothing and I have to check for that in Swift,
you that's taken care of in a sense by the compiler.
So, so like so if you go to hear what's happening now is, I've got something of type string, question mark.
So this is known as a notable type. So Chris they say they notable type things with the terminology I could remember because I also have Caitlyn terminology my hands up but it's all the same thing.
So, Neil is just like the empty pointer.
No, no question mark is in a data type that doesn't make any sense. But just think, you basically get back from read line, even you get back a string or you get back nothing.
And nothing is designated as nil. And here, this is an error because we're comparing this, we're doing a string comparison here.
And the string comparison is not valid if this was in fact, not a string, and in fact is just nil. So it's basically going.
Whoa, this is not cool. You can't do this.
So.
so you basically you unwrap something what it means, what it really is saying is you take a value that could be nil, and you decide whether or not it is before you do stuff.
So, in part two, but notice the whole, so there's also this big thing of.
symbol.
So, what I mean here is.
So, as here is defined as.
Since of type string question mark, it will always be of type string question mark you can't change it. So, you can't actually use it anywhere where you expect something to be of type string, which is which is why this isn't good enough.
This is what the if let construct
is why seller name equals s takes care of this.
By this, if let basically means that we now in effect have done this, this branch of, if this is a vow, this assigns name, and it has a name is going to have a, you know, it's gonna be a type, you know that the unwrapped version so the here, it will be
string versus string question mark. So if this succeeds, and name has a valid name, you run this. If it doesn't, then you go here.
So, it's so the question is What about if S does not equal nil, that is perfectly fine, but we still have to also we can test whether SS a name or not.
But we can't do anything with us.
So, oh yeah so that's the question, so.
So if we did. So actually, if we did let if we did, if, let s name equals
is actually a better way of structuring the code.
Yeah, so so you see here now, we have name name is going to be valid inside of this clause of the, you know, the then cause of the if statement. If not, that's not a valid name.
Now if I, if I do this, what it should do is cannot find name in scope name is not valid in this part of the program it's only valid and then clause is not a valid name in the else clause.
Yeah. Okay.
So, but no. So the question is now what's actually happening here when we run it, it. So, this is a funny thing is, why does.
And okay that's all good, and if I just entered any empty name, you go like, well,
because when I entered that I still gave it an empty string mentality you had a question.
Yeah, so I'm trying to wrap my head around this statement, it's kind of a weird thing.
So, if let name equals read line you are assigning name to read line and that branch. I'm assigned name to the return value of relying right yeah okay and then basically visit evaluate the true if any value is given at all and it goes to false.
If it's know if there's like literally nothing. Exactly. Okay, perfect, but that but notice the type of name is known at compile time, it will be of type string.
Because read line, always return something of string question mark.
Oh yeah. Okay, so how does it know if it's string then like name equals.
Because so this is, this is the type inference. You don't explicitly specified types, but it figures it out, based on other information.
Okay, All right, because it knows read line is declared to be a type string question mark so it says Well then, you know, Nate if you just did an assignment, then it would be string question mark but it's not so you're doing this, if let so okay now we're
getting an unwrapped value we're getting string. Oh, because you're doing a flood, then it's like, okay, it's got to be a string, kind of thing. Exactly.
Okay, that makes a lot of sense. Thank you. This is the unwrapping process this if lead is an idiom for unwrapping values.
Gotcha.
Michelle.
Um, yeah, so I understood what you're trying to say over here basically just making names storing using name to you. See if you are basically starting a string line view inside your variable s.
But my question was, what if you have let name as a global and not inside the IPS if statement scope to you, can you use it in the statement as well so the key thing is to let us associate a name with a value so if we defined it outside of it.
This would you would basically be getting a new value, a new name like you'd shadow the other one.
Okay, like if I could say, you know, var name equals A nil.
And really, I think this should allow me to do this, but the name here inside of the scope is completely separate from this name will affect getting a new name.
You know this is you know nested scopes.
I don't know if you've talked to our vehicles talked about nested scopes.
Okay, So, so there's this idea when you, when you have the same name, twice.
Oftentimes it's okay to have the same name defined times but they're always asking me, well how do you disambiguate and normally what you do is in a lexical scope language IE a language, which we use, where the meaning of things based on the text of the
language you look at kind of Interscope the innermost no definition of it and that's the one that counts. And the ones outside, are hidden, they aren't eliminated they still are there.
And once you, you know, if you elsewhere that one might be value but inside there, it's going to mean nothing.
So, um, so if you if you use name inside the ads statement now. Is it going to look stupid.
Oh yeah, so.
So, This of course will never get triggered by.
But if you do this, this is this is syntactically correct. Now the reason why read line can return nil, is because if you're reading from a file or something and got into file, you wouldn't get an empty string you would just potentially get nothing.
Edward his question is sitting.
There's a saying.
But they have the same name.
Exactly.
There you got, you know, I'm using the same name name, if that's a little confusing, call it, and we'll just change the end.
Okay, so there's. So, if saying if to bearable and one more time Why is lead time and they have the same name, or not, you know, it's not var versus let I could say this is let here.
It's just that when I say this let here, this is going to redefine whatever end was in the outer basically outside of this.
But isn't the lead type channel we defined once and will become constant. So, to maintain your sanity.
Don't do this.
But because having a name here in a name here and they're both the same name and you're like, which one is that here. That's just a recipe for confusion.
Right. Yeah.
But
don't. But that's how do I do I say this.
I should wait a second, I think I might have a way of doing this, Let me see if this works.
I think I can enter Can I do control D.
There we go. Fight control D, which means, and the file. So then it returns nil.
And then you get the else clause triggered.
Okay.
So when you press enter without anything you get basically an empty string.
That's why we don't, that's why we don't go to this clause. we have to make it so there's no input.
I lose control Diego.
So what you said you did control D was, yeah, control the in control D and Unix like systems, including Mac OS is if you type that in a terminal, it means end to file.
Okay, thank you.
So that's a little thing that says okay inputs over.
And that's a little trick I show more an operating systems and stuff but it's uh but yeah you see like this is very small amount of code. There's a lot of ideas here.
And there's a lot of weird stuff that's that's there so it's like whoa.
Brock your question. Yeah, I just have a question about the empty string, a no returning like pressing enter on the console when you do control the rd both different cuz I know one is no luck when you do control diva, like, let's say, hitting that enter.
That's an M. Is that a Nola as well or that's just empty string. If you enter is just an empty string.
That's why we. That's why we get different branches when we run it
So I just hit enter.
It does Hello, but with nothing there.
But if I hit control D, that means I've ended the file so basically realized like I didn't get any input, you know, because otherwise read land goes, You hit enter, you entered something used in type any characters but you can enter.
Okay then. Yeah, exactly different types. Yeah, and they noticed that if you in this, in this else clause, the end that it's referring to is the one out here with the lead.
But inside here this end is referring to the result from read line.
Yeah okay again to the, to the so this is a confusing concept in programming languages, it's known.
The concept. So what we're talking about is, this is, you know, so
if you look up lexical scoping,
you'll find lots of examples for explaining the concept it's worth a pro Doc, that's interesting.
What exactly what is lexical scope.
So you can, you can look up things to explain the concept but this is an important concept here.
Remember, which is swift
document documentation.
Know this swift provider. So this is the.
If you want to get the full.
So, this book is not at all required, but if you're wondering like how is this language, working, as I said, Michelle, did you have a question you have your hands up.
So Anna, so just to understand if Neil returns a value it will overwrite the first is not actually overriding it, it's shadowing it, the value is still there.
So, in particular, let me, I'll show you how I can prove that.
Okay print.
So,
so I can talk my name. No,
no, it says hello Bob good by nll.
So, oh, by the way.
One of the key thing. One of the key skills that you should be learning is the questions are all coming up with are very good questions I'm happy to discuss these sort of things in class.
This is exactly the right use I think of class time.
But the way you should answer these questions, so there's a real tendency nowadays, that when you have a question that you do a search and say, what's the answer there.
What's a much better way much better habit to do is to do experiments.
So that means that you go and try it and go like well if that's true, then this should happen otherwise this should happen, do experiments first, and then if you don't understand your experiments go and search for the answer but try to get some clarity
in how things work by like messing with the code.
So okay. So,
yes, only have is yes.
Yeah, I can't. Perfect, perfect explanation calm. I'm Stephen your question, a question and then, my dear.
Yeah, sorry. I was curious if you can access the global end of statement.
Like always do that.
You can in the L statement you are but not in the then.
So, there's no way to say like this stuff, and I'll give you the global value. Nope, nope, well actually there might be some way in Swift to do that.
I can't see this but that's in normally in lexical scoping you can't access the outer scope, but I can't say in Swift what there is a way but if you're trying to access something outside the scope normally just changed the name you're using, because you
met you created this problem in the local scope.
So don't do that.
It sounds good, Thank you.
So you might go. So this is a, so this is command line stuff. I'm not planning on doing really much in the way of more of command line stuff here, I'm more demonstrating this to say like, you can do this, it's there.
Swift supports it, and in fact you're going like can I run these binaries the command line, oh yes you can.
Because I can go to. Hold on. So, where's the build for no okay so.
So build folder and Finder.
So if I do this, it's in this really weird path so me library development Expo whatever it's got this. It's built in this temporary directory, but if you go into the products here, and debug by.
Here's the binary.
And there it is running in a terminal and so I could run it there. And so I say, I'm off.
So, it's a full fledged command line binary you've written in Swift, and you could build it elsewhere and you know use it elsewhere and it's, you know, just like any other command line program.
So this is real, but
this is just to show you swift as a normal programming language with some interesting quirks.
But what the, the stuff that we're really interested in is of course this.
And so we get this kind of stuff.
And this is not much code but there's a lot going on here.
So, I want to walk you through now kind of the basic idea of what's happening here.
There's several concepts here.
So, the effect of importing foundation that other program is like nothing at all. In fact, you could probably deleted and work but so now here, this program we're importing swift UI.
Okay, and so I can, I'll demonstrate this, but you are going to play with this one side, you know we all stopped, I stopped talking and we all start playing with Xcode.
So,
this is the heart of a swift UI program.
And there's a couple of things to note so you're importing swift UI.
There's this content view previews. This is strictly not necessary for the functionality the program. This is used to make previews work in Xcode, it's boilerplate code, you can mess with it to change how the previews look, you can basically ignore this
so this code doesn't exist. This is just an import. So, what we're really worrying about is this.
Now this actually isn't main. If you mess around with the program you'll see main is somewhere else but essentially what main says is render things with this.
And this is a struct.
So this is a struct of no name content view which is a type view. And that's essentially what you're doing when you make these applications when you're talking about a screen.
Your, your interface is a view, which is made up of other views and views are of type struct content view. So a struct is kind of like an basically objects in Swift or either structure or classes and fundamentally structure immutable, and classes are
immutable. So know that, that, that, that part is important to remember, when you think about some things but for now we can forget about it.
And every the key of you only has one
property, that, that, that, that you know in order for to conform to view it has a body, and the body is going to be another view.
So, which is, it's kind of recursive, but you have you have a you know, a content view of type view and inside of you, there's a body.
I guess this eventually bottoms out and something of, you know, of swift UI. But notice this some view like that sounds almost flipping it some view. But this is to get around the type system this is basically saying it's going to be a view, which is
actually going to be something else more specialized in this but I'm not quite sure what you figure it out from compiler you figure it out from the body here.
I don't want to have to figure it out because it turns out it's a pain as a programmer to figure it out. And then what I've got here I have a V stack, which is a vertical stack of things.
I have a text thing which is text I've got a text field which allows for input.
And then I get the number here.
And then I've got a rectangle and the rectangle has these property you know I call these methods of the rectangle. I want to stroke it with a certain color with a certain line with and it's a size, and basically its frame is going to be this width and
height. So, okay, we're calling this you know this.
Basically you think of this almost like a.
What you call the
object constructor.
And then the object that comes back we call its methods, and we're calling the stroke method and we're calling the frame method on it, and we're giving it these, you know parameters and we're, you know, saying it all up.
So, we're going to be really explaining what all is going here.
In a lot of ways, but I want to explain this line right here. And I'm going to explain this line in a very simple way we're going to go to our other program and change it.
Because you kind of understand what this is.
And instead, what we're going to do is say
up
front that we don't need that.
Let's simplify this. So we're going to say,
will say, you know what,
n equals three line.
You're actually needed some important was the time actually
and.
there we go.
So I've just simplified the program immensely.
And then let's build this
or.
So, in Swift, there are functions and their methods and stuff. It's okay.
So, you indentation does it indentation does not matter in Swift.
So that's what I'm so this is what I.
This was the whole point of this little exercise is you're looking over here at this code here and you've got this question mark question mark here. This is a little bit of magic.
And notice what we did over here, and this is me demonstrating it Look, this is basically doing the same thing as before. Notice that, what I did was I said name equals n, question mark question mark.
No Name. So what this means, this is a way of another way of unwrapping a variable and.
Exactly, is no name the default when nothing is entered exactly when n is no instead of name getting a no variable, it will. this is the default.
So is it just a compressed if steam is not quite compressed if statement because you're actually. The only thing you're doing, if it's if it's nil is giving it a new value you can't do anything else.
You just have to just get that value.
So, notice here, what we've done here is we have a text field. You're doing some, you're getting some input from the user. The input from the user could be nothing.
And if the input from the user is nothing.
Then, you know, if people in the US is nothing, then make it 200. So notice Why could it be nothing is because we're getting a string here. So, size S is a string.
This dollar is this we're operator thing which don't worry about it, you don't use it in most contexts, but you use it for things like this, considered syntactic noise for now.
But this, you know, we definitely don't call this method on the thing texts, you know field returns. but sighs This is this variable here, it's, it's, it's assigned to the empty string it's private.
It's a variable.
And it's got this weird state declaration thing here which again, we'll talk about that.
But this. What this does is, if it turns out you type in like food, instead of a number, and you try converting it to a double IE, a floating point number.
When you do that conversion, you might get something that's not a number.
And if it's not a number. This will return nil. It's because the conversion failed. And so this way we make sure that size, always has a valid number.
And so the default value always, there's nothing there is 200.
Yeah, so, so that so when you play with this you'll, you'll see but this is, this is the default for size if there is not if we can't do this conversion properly, we get a size of 200.
Yeah, so it's kind of mixed up cause and then we get our rectangle.
Now, let's go overtly go to X code here.
And let's now.
Can I put my closest project.
Okay, and then.
Okay, so here is square one is the program shrink this window a bit this is a little large.
So, okay, that's running.
And we'll let
the simulator should sorry I should have kept that running.
Oh, here it is, it's booting.
Oftentimes the simulator won't come to the forefront when you do that so you have to make sure to select it.
To get it out.
And it'll give it a second. And how old your computer is or something. Sometimes it just takes a second to initialize
got working last updates.
Im one machine is much faster, but it's not my primary machine, my wife more use it so I have to borrow it from her.
And she is like to give up per machine.
Come on, it's not working right so if it doesn't work just go, you know, click the home button.
Go back here.
And normally should come up at some point, and show my square.
I There it goes. Uh, go ahead and ask your question, projection for uploading all that I'm.
I'm not going to go through the whole process of creating an app like upload, I mean there's a whole build thing and submission and some if the App Store.
If you wanted to run it on your phone, it's actually really easy you plug in your phone or your computer, you select it from here and then you just go to it.
But if you wanted to create an app to upload it to like the app store that's that's a little that's more complicated and frankly, outside the scope of this class.
So now the square sides you see this here
knows that's the same 300,000 whoa too big.
400 Whoa.
Yeah, the 30% Commission is on it, as on sales.
So, anyway, you're,
you know, so one of the things to notice here is, as I change this it instantly updates the screen, as I type each character.
Where was that here
in this code, where did I tell it to update the screen.
With this as I change it.
Blind 29. No, I did not
kind of the state variable kind of basically in Swift UI.
So,
so you've all had 1406, right. You're 14 of six. For some of you, unfortunately six. Okay, so in 1406.
You got unfortunately six, what you're going to learn.
Yeah.
So is there a graphical user interface.
You know, and.
this is your standard set of things you do in a standard GUI interface, you know, an event happens code, your code processes the event updates the state of the program.
And then, the program updates the interface.
So just understand that this updating the interface is a
is a task that happens automatically for you, and we'll see the dynamics of this and it has very large advantages.
But some other witnesses, but older frameworks, you do this manually.
I'm here. It's kind of a model view controller things right yeah so
repeat your question.
Yeah, the question so I'm from what everyone wants to know flyers like I'm going to be working in tie game, we could like a bit at different times we can update several times, or just walk so depending so let's say if an hour application you be needed
to update at different intervals in our program.
Is that possible in Swift, or is it only repeats by itself, what does it figure it out.
There are ways of changing things of course.
But the idea of swift you so it's not Swift. It's swift UI.
Swift is just a programming language, and there's different you know, things are about and you can use swift to Bill UI kit storyboard apps which is the classic way you would build iOS apps.
Swift UI is a much newer technology it's actually much closer and it's designed to something like react.
And the idea behind it is you don't want to manually update the screen, because it's too easy to mess it up.
You really want the screens to reflect the state of the underlying application, you want to declare that here is my program state, and here's how I go from that state to an interface.
And that's what you specify in Swift UI is how your interface is connected to your state.
And when the state changes.
Swift UI automatically repeats things you don't have to call an update function ever. It's just done for you.
And in fact, if you ever see yourself trying to do manual updates of the screen, you're doing something wrong, you're thinking about it wrong. That's not the swift UI of doing things.
And this is the other, but in terms of big concepts like I'd say the two big concepts of this of right now we were talking about your one was this whole thing of types and non knowable types and you know and then the other thing is,
you know, state based interface management.
So, if you learn react.
It's got a very similar model, the really big difference is swift wants to do everything with a compiler, instead of having a dynamic language like JavaScript manage everything so in JavaScript, you can have variables that take on extremely different
values at any time there's not a specific type associated with a variable name.
Not the case and swift now it turns out to do dynamic things like this to do it in a stack like typed language takes a lot of fancy types.
The other way to do it is just to get rid of types and essentially you just points around pointers and cast things and stuff. And that's class how you do it and things like see.
But here we're doing something different, which has a lot of a lot of reliability benefits but you do sometimes spend time fighting the compiler and build environment, because it really what that means is not you're not actually fighting it it's just
that you don't understand what it's trying to do, but what it's trying to do can be kind of opaque.
So pay attention with is all to say is, when you type code in Swift, in Xcode, and you get that little red message or something, those messages matter.
Pay attention to them, they are telling you something, and you're going to learn how to parse them and what they mean but you can't if you can't just ignore them they're, they're going to be in your face and nothing will go until you deal with them.
So that's what I wanted to cover in terms of material. Now what I'd like you all to do is spend time and go through the tutorial. Now, we have another hour, and well less than an hour, and I'm going to make up some, make some breakout rooms.
You all can go to those breakout rooms or you can stay here while you work on it, and.
And we'll check you off.
As you know, basically as you basically feel you're done, we'll go and look at what you've done. And I'm, I'm happy if there's a group of you in a room we can go through and check all of you off at once, and will update your grade and the great book.
So I'm going to create.
I'm going to create 10 rooms, let you choose a room.
Open the rooms, so you can stay here or you can go with your friends to a room and just work on things.
If you're having problems come back here and if it's if it's a big, and I will basically try to help you with it, and you can share your screen with me and stuff.
I'm hoping you all have mostly have Xcode running, if you don't have Xcode running, I can basically look and see what's going on.
You know, this first tutorials always like, let's get things running.
Should the code. Okay. Okay. So is it hot reload, you have to hit the play button.
I'm sure it was
us copy the code and. So, what you attempt to go to tutorial one and start reading through it.
Do you have you should have been able to add those in so I'll share with share my screen here,
what you should be doing now is going here, and doing this. And the first thing you should do is configure your Xcode environment, go through all this, make sure you can run a Hello World program.
Once you have a Hello World program, then you can take this code. Copy Paste it and replace the content view dot swift in your in the program you created it.
And, and then try running it, and then once you get that running, then you start doing the tasks.
So, my most important thing is make sure you get the code running, and then you can start filling the same.
So like if you just get it running, I'll give you three out of four on your system.
I want you to at least do some of these tasks to get four out of four.
So
go start working.