iOS App Development - The Basics for Beginners | Andy Wong | Skillshare

iOS App Development - The Basics for Beginners

Andy Wong, Teaching iOS during my free time

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
5 Lessons (47m) View My Notes
    • 1. Swift Basics - Course Introduction

    • 2. var and let variables

    • 3. Functions

    • 4. Classes

    • 5. fileprivate & private WHAT?!?!


About This Class

The class is currently in development. I will be adding videos as soon as i can get them up. 

This will teach the basics of Swift 5.0. This does not include SwiftUI. In this class you will learning the following:

let vs var



public vs private vs fileprivate


and more. 


1. Swift Basics - Course Introduction: Hello, everyone. Welcome to my introduction to Swift Basics. Course. My name is any. I will be your instructor here for this course. Ah, a little background by myself. I've recently graduated college. You have about one year experience as a full time self or engineer, as I was. Engineers have four years of intern experience and four years of I was experience, and in this course you will be learning the basics of Swift. So for this course, it's generally for people who have basically our first time programmers or you might be an aspiring. I was programmer with a bit of basic holding knowledge like, No, you're let's environ. Maybe some class and functions. Um, this course will allow programs in the basics On are also for programmers who wants to learn how to apply the basics to basic Iowa's application, or for even designers who want to kind of bring the designs to life into an application. So who is this course not for well, this? For anyone who actually knows anything about war that's funks functions public and private functions or classes or even knowing storyboard the basic level or even professional programmers, discourse really isn't for you for swept. This course it's really learning about Swift along with the basics of programming. What? Using Swift. So anyone who has a good knowledge of our let's functions and things of that sort, this course might get a bit boring. Of course, you're welcome to take this course I would've stepped, passed some of them most. These quarters, they're gonna have titles that, you know we could have learning for that video. Someone skipped to mawr, storyboard, tied to video or even studying with the class project. If you really want to start this course as well, so what? You will learn from this course. If you have a hard enough that you'll be learning bars, you'll be living. Let's public versus private functions class on some story sport basics. You will also be learning a little bit about optionals, and you will be learning about a bit of file privates on aesthetic functions as well. Also a little bit here and there, but basically you're gonna learn the basics of programming with Swift at the end. Of course, you should be able to build a basic function application that will like it asked, attract most plan and divide two numbers. And for a bonus project for this course, I have also added ability to allow you. If you are able to kind of take this to the next level, being able to do more than just two numbers will be able to ask the track. Most would divide any not level and more than two numbers. So thank you for watching this introduction and hoping Georgia's course. 2. var and let variables: everyone. Today we are going to learn about the basics of X skirt, along with learning differences between bar and let for most of this course. In the beginning, we are going to use the playground, so I still has to kind of places that even used to code. There is a playground and there is extra projects. So for a playground, it is really meant for you to kind of test around and kind of play around with code. While extra product is basically we created app a Z can see disappearing. Now it is a brief explanation where you get to basically playground exports and new ideas, while for a project you're actually building AB for I rather be iPhone iPads, Mac Apple Watch or Apple TV. Uh, so we're going to start off with stunning a playground, and here we are. So I am running extra little 0.3. As of this time of this recording its course, I'll probably update this as time goes. So what we're gonna do really right now is we're going to start with a blank playground. You could always, through single view, basically good to have a single view application in the playground, but because we're learning the basics of everything right now, we're going to start with just floating Just basics. Right now, we're gonna put this somewhere, so just make sure you need me course as well. So for me, I'm going to just name this of our versus Lutz. All right, so once we've created here we are. We have a basic extra project hair. Um, so to get started before you go was starting before. And let's This is basically import so important. Basically imported from libraries with Cody can always put in a different library and kind of the frameworks that will help you out with figuring out what to basically be able to use . When you import your kid, you can use certain functions and clauses in Senate, that library, uh, Castle, that you don't want this or not. Okay, So to get started, we're just gonna remove everything. I used to remove the hair back space. So the difference between let's and bar is that with a let's variable, you are allowed to change your not want to change anything in their variable. So if you set that value, you cannot change it. So Let's say let a variable. You got 10? Yeah, I say a variable 12. This should not work. So as you can see here, it gives your error. It says they cannot assigned to value a variable, is it? Let constant versus far be variable. If I said that 2 12 then here I see people equals 2 14 prints Be terrible that run here, present play. But run, Do everything and you should see some things here in the council. Also, here we go bearable a variables. 10 be variable is 12 nab your becomes 14 in my hair where prints be variable. That's what we get at the strength. So we do print statements at your prints out of the strength I see us here. I hear this Our prince, um we could also change more hair. So could you be variable equals toe 50 dough and it's to be durable again. And if we wanted this time, as you can see 1st 14 15 and trying from favorable hair. And just so you know where we are from your stars in here, just the idea what's going on? Play? Boom. So we know that this is be variable is a variable and trying to a bearable He could've 13 1 23 is not gonna run. It's gonna gives that message on my hair. Tells you, Treat Tovar that's happened starts to really the basics of a letter of our 100 variable. Essentially, let is basically, once you said it, you can't change it while bars are. You can change its mutable. So moved this hair while we're at it. We're gonna also be living options here. I know that this is a foreign led the options was kind of something that we're gonna kind of Tszyu along the side. So I want to do this right now as we are doing the letter of ours here. So to start, we're gonna keep our variables hair a variable and that, um, be viable. So there's different types in variables. There's and there's there are doubles, there are loads float. They're also strings. Character for those different types is basically I'm trying to say and there's also a kind of custom types and custom objects. But that's the for type, of course, because the beginner's course so resistant that so get started gonna have far a variable off type. And so my hair we have available. That's changeable. And it's telling you to start off as no, because we don't know what the value is. The benefit of doing a variable and commune optional sometimes is that there times where you made me not have a value. A hand. Um, there's been called asynchronous code or a sickness functions where basically, we try grasping. For example, if you were trying to grab data from an A P I or some sort of network device, think of it as you being the person who was trying to fill out a form and you had information form yet. So at that point in time, a variable or the name of that person is emptied or nil. So that's what is the point of it on optional. And when doing so, when you do prints a verbal, this is should print nil. But when doing so someone with this it's better to do it safely because it may crash because it's no printing is finally tried access. It's gonna be a problem. Let's just say if you want to say you want to set it and it wasn't existent, it's gonna cause some. It's gonna break basically, if you want to try and grab that valuable your prince and it's perfectly fine. So one way to make sure that there is a variable is to do a force cast. So So for some wrapping. Sorry, What? This means that you're forcing its unwrapped and only reason why I should do this is if you know, for a fact that at this point in time that you axing is variable. That value actually exists. If that does not in this point in time, the app road crash. Um, obviously here will not because it is no, that we only printing it. But as you can see fit, era and this But I found no while trying to reptile optional value boom. So to fix this issue, uh, the one way to do is to check of its empty if a variable, that's not you couldn't know. That means that is not kneel in there. Is it about you? It was a prince a variable, and we're gonna force it now if you run it this time, we should not run into an issue at all because a variable has there been ill right. And to make sure this whole thing actually ran, we're gonna prints finished program. Run it. And we should only have finished program. Now, if we freeze on bit, set available hair every 7 to 10 and reverted this time we should get off 10 and finished program. This is basically the simplicity of using optionals. It's essentially allowing us to have the ability to make a variable anti at the beginning of time may seem a bit complicated at this time point in time. But as you get to more of an apse where values that exist immediately, using options is really useful for the readability of curd and just being, you understand code and much more. Thank you for watching this Barbarouses that video and the bonus off liberal on the next course, we're gonna learn a little bit about functions 3. Functions: Hello, everyone. Welcome back to who are of course today we're gonna be learning about functions. So we are where we left off yesterday or in a previous video about let's and bars on a level of optionals. And today we're gonna learn, love them or, um, and get started functions. So to get started, just sort of be are more familiar. But if our of our lesson optionals, we're gonna have a optional far, and we're gonna have a let variable which we will set to a type of event. And actually, let's do itself a double. We're gonna set a ton, um, for floats and doubles, you had to give it a planetary. Always give it a 10 thief program would know what Radha Swift and noted, This is a 10 and you want to type double. So the reason why I wanted to do difference who different types, because I want to show you a bit about kind of the difference is if you were trying to print a very be variable. So when you're trying to print this, it's going to gives an error because you cannot add between it and a double, and nearly in your during in Matthew would be able to have you trying to add a decimal in an integer. But for a code has be very specific so internal. Do anything between between two different times. You have to kind of bring them some interaction. So here, to be able to print this, we're going to create something called a function. Now function contains several parts. The first is the name, then inside of it. If the print is set of parentheses are parameters, so we can have remember one and everything Time given parameter tell what types of basically what you're gonna be passing when you call a function so resemble here. We're going to do double. And when you decent with this, which is a dash and for carrots, you give it a type of this is busy telling a return type, then Kelly Praxis, which is basically what will happen inside of this function. So think of functions more of a action. It's more of a way or method, basically instruct between two different objects and ultimately either returning a function or doing scissor action. So in the situation, we're trying to return something we can also create a function which has Ah, no return could be like this. And I was with a different name, so we'll probably do it Name in return. And these two functions offices probably named name and name return. It makes no sense. So function name usually means I'm you give the name of what this action is going to do here. We are actually going to convert double to end. Um, and here we can do a, um so the difference. So I'm here. We're returning it. So we can do Is convert will be returning and this one would be convert Convert of convert . Sorry. Can't smell tonight. Convert double to its and we're going to remove in the return. So here we are. So we have two different functions. One is returning Something in one is not these busy to functions that can't. Basically, this is one of the raising use functions. Um, so, yeah, we have function. Give it a name and parameters. You can have more than one. So one of you have more than one parameter you can do a comma. We do parameter to do a double again in a situation we even want to promise here. We actually want to come remembers in the convert function eso we're gonna go hair and Harry given parameter two and in hair, we're gonna give it a double. And the reason why we're doing this hair is because retracted Virgil's end. We're gonna tell it that which, correct, what Primer one is going to be number gonna switch over to ends. And the second was basically telling you which primary want to switch over to all this is really bad code. Obviously, we never really want to use this count, but I just want to give it as a point that you can create function most parameters in ways that we want to use it one. So here the point of using this function returns double to end mainly is so that we can call it hair we could do with her groups return double t end to a parameter. We're gonna put in be variable inside of hair and essentially, what would desist will do is we will pass in a double and no returns and into and that way , so awfully hair seems to be stuck in a situation which is which religion before which is checking with them, Not a variable is nil. So we can do two ways. Just as a refresher can do is if a variable is not, you know, then we want to print everything here and for the force in rap and other way to do if, let's, um, a variable, not know just because we want we know does not know where just spaces recorded a variable because so do curly brackets here and we can do print again. You can copy it, trying out the copy code as much. It's not good, but for the sake of this, begin to it here because it's going to take a lot longer. We don't do it this way. So here we have two fortunes. Perfect. Fine now that they are functions. So here's two with me. Do it. This both work. So just so weak and understand this work correctly, this is gonna be a no check. And here we get a print, a flood check. So basically, there's different ways to check to see the values now one knots. And if there actually is a value individual that we're trying store, and if there is that we do this. If not, we don't permit because you don't want to force unwrapped. This had a time without knowing of its No, not primarily because they were trying access it in a different way. And it's no break the code or break the application you can create. So back to your function returned double to end in Hamburg have parameter of a double. And what we're gonna return is a switch has some handy function on its own. And what we can do is just dio return and forever one. And it's really turn from everyone has and which basically is pointless in the sense that in reality we only create own function for distance with has his own weaken religious of them desk? Instead of doing this, we could have just on this little time for both, obviously, and so create all function. But for this course, we try to create a function, teach you how to do that. So this is how you do it and to make sure it works again. Press play and see if this works. And again we should not get anything back because a variable has no information. We did not give a terrible value. So, um, we should put a variable and give it a vice. So we're gonna do it. Hair a variable close to 10. Um, and if we run it again, we should get 20 and 20 years ago in new check if let track they both return 20. Perfect. So another thing re can test out here is that the function is an action to be up front. It could be anywhere, as long as with any class which we would be living in a video. But for now, we had to put it somewhere. So for playing around, you have to obviously put in the certainly kiss you for calling it. But it is in a class we would have to, which is something top on another video. I'm going put this code back to where it was. We will learn more about kind of higher, give curd When we used classes in the next video when we started classes. So offices of really basic implantation on how Teoh use functions. So here we're gonna have you created a function and we can call this ad and we're gonna do a number of one off and and number two of. So obviously we have a function as things. But this is just a street How you can do this. So to make this easier So we revert to secure twice eyes you can see the the A V about plus bubble block we want to do is really just call a function putting these two variables into it and it will return us a value so again to return value. You just put a dash for character and a type you want to return. And here we're gonna return number scripts, Uh, number one plus number two. All right, so here's their princes a variable and printing. That's we're going to do a variable and 2nd 1 ISS turned double toe end and this is gonna be here. I would be standing up hair. It's going to change is actually instead of copying peace and coach to show you as a copying, could it bad we do ourselves so that anything that stuff is that you have pre fills so we could do just available, not know, and turn a double and be variable, so hair we should get a similar thing here. We just like a 20 the print statements. It should be exactly the same. Perfect. So this is really the basics of functions. We could do a bunch of these. You can create functions the point of functions just for the use of readability said that you and also that he's of basically being reused, function busy when you do things multiple times, being able to reuse them is much more handy than basically copy and pasting code, as I've shown you a few times before, copy and paste and gets a little out of hand eventually, and it gets a bit messy. So doing in this way makes a little bit easier, and it's just a lot easier to read, and much usually reuse functions versus recreating. So that way we gain more complex algorithm. You put into a function, and all I need is call that function and I'll handle rest the work and that way. Also, when you do D bugs, if there is a buck, for example, where hair I put minus and let's just say you copied and paste this a lot of code. I was like 15 times. You don't want to change 50 lens codes from plus to minus. Instead, he just changed it hair and one function instead of plus instead of minus two. Put about two plus and ball. These functions his fixed now versus doing the other way. So just to show to you that minus hair and we ran it, obviously we're going to get zero for both of them. And if we had the original code, which was basically adding it, but we would just be basically printing a variable loss, the turn go, Prem will be variable and let's just every minus hair and just for easier than just copy it is exactly what a bad code would do. Hair. You would do that, then we would get something wrong, right? So we're gonna dio just so that we have an idea of difference between correct and incorrect . We're gonna do that on reducing. They're so you can see as you get a copy and pasting a lot, it kind of gets out of hand. And if it's topping, piecing the wrong code and numerous times you'll end up with bad code, plus very hair. Add and run it. You'll see that we have the correct functions. These two are correct, while these two are still incorrect. But in order fixed up on the press plus hair and come back here and do a plus. And if you have 100 lines of these, it's gonna take a while to fix versus just doing in one place. So I hope you understand and learn a little more about functions using Swift and the next video, we'll be letting more classes and taking this piece of curd and bring it into in their level. Thank you for watching A C isn't in this video. 4. Classes: Hello, everyone. Welcome back. Today we're gonna be living in my classes on philosophy. We're learning about functions and the video before that More than the bars. Let's an optionals. If you are watching this video ahead of time, you should already know little more bowel functions, Mars and lots. If not, I would recommend you going back to those two videos and wash those first before coming and watching this video about classes so they get started, we're going to talk about classes. So what classes are in reality is really just basically, um, kind of a class is really a place is kind of container that can handle functions, Let's on its own and plus, do get Colin complicated their Children classes, parent classes. And what this means is that one class can inherit functions from a different class where you can get a little confusing. So just to give you an idea in sort of code, we're gonna skip a few lines here and go down below here and we start here. So if he had a class a, um, right here, let's just say just for ease of it, really. Call it class parent and we're gonna have a class child, one of type current. So as you can see, it's a little bit different. Already so apparent can inherit things as well. But for these of this, we're gonna have a parent and first child. And essentially, a parents can have functions. Let's just say a parent has really learned how to eat. Um, so here, as a child, you can also learn how to eat. So because you have this function from your parents and you can override eight functions So , for example, parents can learn how to eat one way, and a child could learn the from the parents and override that function and learned its own way. So, essentially, in one way or another, uh, parent class is busy over RC class, and when you inherit from it, you take all its functions. So, for example, if I did give it a kind of a variable or a let age was 10. If you're trying to grab a chair, you can, and this ages from the parents excites a repressed prince age. Um and we're gonna print my hair new A child one. Just because we have this code hair and I don't want it since affair. So over here, we're going to run this. And if you can see, there's basically thing here because we have never called the function eat. Um, so we don't want to call it. We can just call. So here we have it. Or are function of each that we are inheriting from parent. We also have aged from parents. So here we actually want to do a little differently. Wanna minutes? Privates? Uh, you will learn a little more about this in the video, but for just learning the clauses. Well, just for instance, of it, making a private means that as a child here, as you can see now we have a, um, error is because we cannot access age from the parent level. So here we actually don't want to do it primarily because we want to actually know you pray as a child. You know, your parents age. So here we have a function, right? Parent has a function, and child has a function. So for parents, we're gonna prince age if a child but your print child one just for for that also. Just so you guys have an idea of how to use a little bit more string in circulation here. What we're doing is we're gonna have the double quotes for strength inside of it. We're gonna our actor text and with a backslash open close parentheses we could put available on their two available. So we've run this. Nothing's really gonna happen. We only get to previous code that we had, which was above right hair, everything. Care, basically. And what we're gonna do now is actually gonna change the bet. So in order to access any of those were they kind of have an instance of these classes. So let's parents equals to a parent instance that we create this. This is initializing a parents, as basically miche loving parents were available name and it's going to current. And we could dio print her parents. Thought agent, we could do Prince turned eat. So as you can see, there's a cross. Basically, what this means is that we're going to call a function on dumb, has no return. It's a hair. From there on, we can create a child, recalled first challenges for the fun of it, and we're gonna have it. A type off child, one So obviously for two, activity of districts should be a child. And then first child, she s So we should do that. Would you do with this? Just removed? That's child. So it's more intuitive. And here we can only do a couple things. So for print child first child, you can actually access all the functions from parents. So, Prince First child that age is basically you grabbing Asian or parents. It's not its own age. So they're stunt on. We can do prints first child dots eat and at its own function again. So it should be different here. We should get 10 as the age and eat his child. Hair should be 10 and they should be age 10 hair. Whether puts out so you can see why. Harry of Asia 10 which is, but we're printing out hair 10 from hair. We had a 10 again from hair and 10 from child. And this basically because reprinting out of function that returns anti because there is a void culture, which means there's overturn, meant that. So we're basically printing out the empty function at that sense, so essentially, right here is going to see as a child who can hear from parents as a class, you get its functions and or write it and also get the variables that appearance has. So obviously a child has own age. So in hair we're going to create another one, which is called age. So do let age, he goes. It's five to obviously oppression of the eight or 10 when they married. So let's just school of 30 and a child 82 and see how this runs all rights immediately. You get some heresy, cannot run a store. Property of age. Obviously, parent has a child has age. And so the problem here is that by calling them both the same value, you get issues. So the reason why this is an issue is because ah, child is inheriting from apparent last that has the age properly, while both of them have a difference of age. Um, there really shouldn't be sharing these same sort of value, although the parents and the child has its own age. So in order to do this, we're gonna have to do something like this ever Teoh private for parents and president for child. So they have their own age and What this means is that as a child he cannot accept the parents age and my first up. But the child can have its own age. What happens then, is that when you initialize thes functions, you cannot access them this well, but also prevents you from from a child from accessing the age method. So just did kind of get a reference data for a bit. We're just easing this. Obviously, the situation this really shouldn't have happened. Um, so for this, we're gonna have a chair, and we're gonna not have this. So obviously you cannot inherit an age from a parent. So we all set to make this private since in this case really shouldn't be able to access the age of apparent. Um So what this does now is basically means that we cannot access age me initials parents, um, I'll see when we're to fix it is to create a function that has access into this private function was part of arable, and it solves the issue. Right? So here eat is because inside of the class of parents, it has access to a gym off the parents. Therefore, what? We print out this function a protest us the age. So obviously a better name for this function is actually called get age. And this would pronounce the age. And here we're gonna call it, get age. And also, this is not gonna be a function anymore, but we can still do a function just so that our child can still hurt eating from the parent . Um, so here we go. I have to close brogel differences. So here we go running this. Now we are going to have a look Better function and classes. So here we go. Um, parent is age of 30 your child's ages two. And when you do eat it prints out, child. So this is very much kind of adjust of train a class and instead of classic and functions and a point of having a class is basically being you basically inherit from a different class of grab its functions. Uh, it's easy readability and things like that. So now that we've been a little bit inherent since, we're gonna try to take this and make it into some a little difference. So to start off, we're gonna give this class a value. Um, we can call this class something. So we're going to call this plus calculator. And the reason for that is because this is gonna be a calculated class which basically prints off things. So instead of calculated class, I just basically push copy and paste everything into hair. Um, so that's that, um, So we have everything in hair and as you see is a bunch of stuff that's going on already. Uh, just to get started. Um, right here wants to make intent class. We can't do funny things like this. A variable cannot be stored in random place. All this has to actually be in the function. So to do this, we're gonna cup closed all of this, and we're gonna call it creative. You can keep this. So instead, we have heard this outside the basket. This is not part of the class in reality. So this is what we have a calculator. You should not have a values in here as well calculated. That has functions. It will take the parameter and a second parameter, and that is it. So here, we're gonna not have this. So in hair, we're gonna actually take these two values. It's also gospel spin class put outside. So because we have a start in extra project every year on what is a few did load, so you dysfunction would go inside of a function called view devote, which is a basic function that comes out of the kids framework view Did load will allow you to. Basically this gets funded, gets run when the APP actually gets initialized and doesn't save you controller. And that the controller, once it goes to the hierarchy off life cycles and basically hits to be delivered. And this is when everything here will get run around hair. So they just started also said, This is a view did load this could obviously be outside inside of the class function. The only reason why we're not putting inside a calculated class is because of the ship and its own be its own class. And inside his own closets has very rosy trying. Adisa, tractor, whatever you want to do. So here we have a view that glowed function, and over here we see every return, don't end and add functions are not part of this. So what we have to do is a calculator On this calculator, he goes to calculate, we're gonna initialize it and instead in here, instead of eternally the calculator that's return Double end seemed in here, and what we're doing is basically recalled an instance of this class. It's how this incident is class. We have functions that we can do to do the work for us and because his class of calculator has this functions can do this for us. So I have seen this type this I'm so Harry induce hair else. Do this here. All right, so here we go. We have a bunch of functions now, very happy classical calculator. And essentially it's going to have functions. And it's a calculator, which destruction not being as returned double ends and a fortune called ad and then in our everyday low function are imitation. Essentially, we had a variable and its second variable. We have a calculator because of the var is optional recent of a hair on two ways to check. If variable option available has a variable, and once you do that, we're gonna print them out. We called a calculator to do the return double its function and also took it would add between two variables and doing all that. So I'm going to actually coming out all the previous work about parents and inheritance off to classes and we're going after just run this code hair. So right here, we're running it. And as you can see, everything runs correctly. We have no check that we run force. I'm wrapping a variable with a calculator. Return into. Then we have the correct version and things like that and all the answers. Exactly. Correct. So this is basic, the basic understanding of classes. Always, there's a lot more to it. When we started working on the class project of creating our own cock litter and the X Car project, we will kind of get into it into more of using classes and functions, and hopefully we'll bring it better understanding. This really, really is intended for a really basic understanding of classes. I really hope this kind of gives you a better understanding of what clauses can dio everywhere you create functions or create things instead of extra project requires a class , um, bond. One that kind of the benefits, having classes, just readability, whereas you just put everything one file. It's a lot harder read for other coders. Um, and it allows us to organize the code a lot easier as well. And as you can see, it brings this sort of benefits. It is inheriting different functions from a difference class that you may have created right here as, for example, with parents. And we have a child. And, um, obviously we could take this function love further, right hair we could always have done, For example, a second child. Um, it's had a second child. We could do the other things as well. So a second child, we can give it a child type as well. You can initialize off a child, and we could do different things to, um, we'll be like second child thoughts. You know, each self get age. You'd do better things as well, and every trial could be a little different. Obviously, here we exactly the same. So we age. It's going exactly the same. But if we did this reason, what age was too one and we did print e get age and Brenda's, you would get a different thing, so of are so obviously I didn't rebound code of our age really change it. Now we do let like remember, doing a lot means that you get nothing on event because I mean you don't get so Obviously, I dream a code. And if you did a lot basically can't change anything. Once age sets as a very has a lot to variable, you just can't do anything else. So me trying to set age with a lot would have broke the code, but you can see when it sells sex. Tell Second Child a show you one prince out is one. So we just busy Korean default value. So taking to next level of our optionals that we were talking about beforehand, this really should have been this. Let Marr age of type. It's This is what it should have been and from their first child should be set in age because to five, then there's a little bit better. But obviously, like I've said, if let's so we should choose added to do if letter age, um or you can risk it and give it a forcing ref for both of these. But obviously we're dealing with this. If there was no age, it would break the app, so obviously it's better if we checked so I personally if left meant method. Some people, let's interested us where first child at age does not. You couldn't know this was perfectly fine as well Do that That works as well. Same thing. ISS second channel that age is not equal to nil. Well, you want to do that on? We're going to put its half of readability on. Put a space between for readability and every deed us. Now we should get a age of five age of one bombs five and one. So that's basically a get a day of her classes work, You know, you have parents child, and this is really how it works. So again, I hope you guys understood that more parents and child and have inherent to two classes. Um, next video, we're gonna learn a little bit more, and after that, we're going to start on our old master project 5. fileprivate & private WHAT?!?!: Well, everyone, welcome back to in their video in the loss figure we learned of my classes and a couple feel before they really learn a bit about functions. Let's of ours and optionals today we're gonna learn a little bit about private five and file privates. Um, since we live with my classes closet really complicated topic, and I really only want to basics of classes. Um, it's a better topic. Talk about one begins in amore event stage today. We're gonna be talking private file. Province could be really quick video. Um, so in the last video, when we were doing classes, we actually use private a bit and kind of to kind of re phrase. Um, difference between a private is mainly the fact that making a variable private means that in that class, inherited or, um, a class or a kind of an instance of a parent cannot grab age on its own because private, once it's set inside this class, anyone trying to access it or getting instance or inheritance off the class parents can't access age. So to give you an example here, where the child inherit age, I mean, it's I inherited parents but I cannot grab age from a parent's so I can't do something like get age. So if I didn't have our age here, for example, just to show you re trying to grab age, you just can't because there is no instance of it. So that print age, you don't get it. So you might argue that that's because I don't have a variable of it. Well, right here. I can do this a lot. Age apparently. Good. 30 in a different age. Ill work, hair. So just to give you guys an idea, making your private means stats you can access. Um, this variable stuff, a file private. What this means is that as long as thes two classes air in the same file, I can't access age. So as you can see here once I made aged file private meets everyone in this file has access to Osama creating new file here or new playground and inherit parent, I can't grab age again because a file private variable. So if this child function was a complete different file, I would not be able to access age, and this air not would never exist. So if I did this right now and right here I did print age. Um, this would print the age for the parents just for ease ability of its I am going to basically, uh, removed So I was thinking See, right here The air is giving us like, Oh, hey, lot ages. Let rare instance right here. So you don't need to actually say that That's the first of all. We can't change it because of that. Secondly, we cannot force and reps in that actually has a value. Had the time because it led. So we've run this now and we show you here eyes can see all the way at the age of 30. So against reiterate private means that no one can access it So a variable or function can should be private. So we can also dio age get Asia we found to be if you should be private which means that and hair this would not be exit. We'll see So ever had get agent inaccessible due to private protection level. So you do have to function as well. It does not limit to just being under a variable. So that is what profit is for fire privates um, no one can access the function or variable if they are in a difference class if, well, if they're in the in a difference file from that class. But if two classes are and the same file four file, um, there Well, the access to see action or variable. So, yeah, that's the basics of file proper versus private, essentially making something five. Probably anyone in this file can have that access to that variable versus if I put this class. And if a file I can't access this again, while a private just means that regard it's a district in a file private. So you in the same file. It is completely ignored. You have to have your own kind available to do it. It's private, which means that no one has access to it on only in that class, which we spoke of last in the last video. So if we wanted to actually grab age when we do it is to have a function as public that has access to the private value of age, which is right here, Dude, motion get age of just public, which can grab. Any instance are here is to see we can prints at the age. Also, just so we understand this is actually also reviewed the load function. It's imitation reload function, which I explained. Last video is basically where if you import you, I can't have you have you controller that evidence to the whole life cycle of functions before you just see the application or the view of that we control in the application? Um, and if you did Lotus one of these functions and it gets run throughout the life cycle and usually this is where you put the coat in to kind of do all the work or the map that you want to do. So again, this is basically a brief overview of private versus file province. Um, I hope you understand a bit more about this. And if you have any questions, obviously let me know. You can email me or are common and discourse unless reverse course, and he has a comment feature is the first time in your skill share. But again, feel free to contact me in any way. I'm happy to help or reiterate thes Lawson's. So next video, we're going to learn more about classes, functions, Erin, that we've learned in buildings and application where you can do simple calculation, whether it be asked track, multiply and divide. We'll be able to use that and essentially being too do some basic math and using functions and classes to do such a thing as a class project. There is going to be kind of like a bonus project where you can take that project and bring it to the next level, which is busy to gain more than two numbers and adding in what's playing, subtracting. Dividing in very good do with multiple numbers is the opponent project, and that would end the course. He has an extra video.