How to Create an iOS App with NO EXPERIENCE - Chapter 3 | Grant Klimaytys | Skillshare

How to Create an iOS App with NO EXPERIENCE - Chapter 3

Grant Klimaytys, Software Engineer

How to Create an iOS App with NO EXPERIENCE - Chapter 3

Grant Klimaytys, Software Engineer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
7 Lessons (57m)
    • 1. 1

    • 2. 2

    • 3. 3

    • 4. 4

    • 5. 5

    • 6. 6

    • 7. 7

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Learn how to create an iOS app with NO EXPERIENCE! App developers get paid $100 per hour on average - would you like some of that?

Meet Your Teacher

Teacher Profile Image

Grant Klimaytys

Software Engineer


My very first software program was the artificial intelligence brain of an underwater robot in the early 2000's, still the coolest project I have ever worked on!

Since then I have designed and built websites, software and apps using all manner of languages and frameworks. Javascript, Bootstrap, .Net, Python, PHP - you name it, I've probably used it.

These days I focus on building quality cross platform apps using Xamarin studio in C#, Xcode and Swift 2 and Android Studio.

If you're considering becoming a freelance developer then I can honestly say it is the best life in the world. You will have no boss, earn an hourly rate of $60 - $150 and take holiday whenever you want!

Of course you have to learn how to make good apps first, which brings me to my second pa... See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. 1: welcome to this final part off the tutorial when we're going to make a fully functioning calculator app that allows us to perform lots off functions. So 98 times 35 is 3430. This may seem complicated at first, but your notice that when we program, especially in this app, we're going to break everything down into really simple concepts. So programming is all about writing as little code as possible, and you'll see this app is actually quite easy to make, so let's get started. 2. 2: Let's create a new X Code project, so you should be used to this. By now. I'm going to create a single view application. I'm going to call this calculator awesome and leave everything else as it is Swift Universal. That's fine. And I'm gonna hit next Andi, Place it on my desktop. An ex code is going to duel the rest for me. So we have an app that looks a lot like the last one we created. We have a view controller on the main story board. Open up the main dot storyboard and then inside here. I'm just going to scroll down and I'm going to double click on the white space, and that's going to zoom out for us so we can see the whole view controller at the top right corner. You'll notice there are some options here to hide or show the Navigator, and if you click that, it makes the Navigator go away and over on the right. We can hide the utilities to give us a lot of room to play with. Now, when I drag, let's say a label into here and, of course I need to show my utilities again to do that scroll down at the bottom drag. A labeling on X Code is just frozen a bit. Its way to second. Let's try that again. Strike the labeling. It doesn't like that. There we go. That's better. You might have to zoom in to your view controller to actually be able to drop that in the next thing we're gonna do I'm going to hide that to the side isn't going to hit the assistant editor these two circles in the top, right? And that gives me to pains. And if you remember, this was how we connected our labels to our code before. So I'm going to close this. Give us a lot more room. What we can do in the assistant editor on the right is when we hit this automatic up here and we come down to preview, we can go to maine dot storyboard preview, and when we click it, it shows us what the screen is going to look like on the various devices. So this is on an iPhone four inch, which equates to an iPhone five at the bottom. Here, I can click this icon. I can rotate it so we know what it looks like when it's rotated. There's a little plus button in the bottom, and when you click it, you can choose other devices, toe add. So I'm going to choose the iPhone six, which is a 4.7 inch, and it adds it next to it. So if I double click in the white space, it zooms out and you can see the label has moved, which is a little bit frustrating. And if I ads, let's say an iPad. The label kind of moves around all over the place. So what we're going to do in our main view controller. So this pain on the left is we're going to put some constraints onto this label. And constraints are a very clever way off, positioning things relative to the edges off the screen off your device. Constraints are completely controlled by these four icons or three icons down at the bottom , off the left hand pain. So when you click one, it comes up with a little pop up. So let me just make sure my label is selected, and then when I click these, I have a little pop up that allows me to add new ones so right at the top. Here, let's say I want to position this label 76 pixels and those aren't real pixels. They kind of decimal points. But for now, pixels is a fine way to think about them. I went to position this label 76 points from the top, and to turn it on, click the red icon underneath it, then come to the bottom and click. Add one constraint. There's only one because we've only changed one thing. And when you do that, you'll notice this blue line appears, and that blue line tells us there's a constraint from the top of the screen to the top off our label over on the right hand side. In our assistant editor, you can see the label has moved from the middle ish right over to the left, and that's a bit weird. But that's what X Code is trying to help you with its tryingto auto. Lay out your things, and if you only have one constraint, it's going to start assuming things that it has to do for you. So the more constraints we add, the less control that we give to X code on the more control we give to ourselves. So obviously, we need to add a bit more to this label to make it actually stay in exactly the same place off our screen. So let's position this horizontally in the middle and down in our little two bars under one of the icons. We have some more constraints, and luckily for us, we have horizontally in container. So far, I check that on and I click. Add one constraint. You'll now see the preview on the right shows us that this label is now horizontal inside of its container. Now this label is going to be the display of our calculator, so let's make sure we know that's what it is. Click in the top right corner to turn the assistant editor off by clicking the lines on Let's bring back the side panel by clicking the top right button that says hydro show utilities. So in here we have a whole bunch of options that we can, of course, set. And these options are dependent on the thing that is currently selected inside off the view . So if you come to the top right corner, you'll notice there are six sections is a help section. There's an identity inspector in section. There are some attributes size, etcetera. We want the attributes section because we want to do a little formatting on our label, and let's give it a nice funky color. So in the color section, if we click the actual color, it comes up with a little chooser, and we can change the color of it slightly and we can close it. Another label is a dark gray. We can also change the text in here as well. So this is actually going to be display off talc or calculator. This is going to be the display for our entered numbers in our calculator. The first problem will notice is that we can no longer see all of the text, so we have toe wide in this. Let's select our calculator and down in the bottom. We have some more constraints that we want to add, so we have some options here. We can set a width. We can set a height, but what I'm going to do is add this constraint that takes it 10 from each side off my screen and I'll click. Add to constraints and there we have it. And if I switch my assistant editor back on, we can see the label is now expanded toe almost the width off the screen. Now there's one final thing to do here, and that's to send to the text of this label over in the right hand side. Under alignment, you can click the center button and it pops it right in the center for us. So that is going to be the display of our calculator. In the next lesson, we're actually going to start adding some buttons for the user to press in order to do calculations. 3. 3: Every good calculator needs buttons, and our one is no exception. We're going to add the numbers 1 to 9 and zero, and we're going to add a plus minus divide and multiply buttons to our calculator screen. So inside our main view controller. And if you don't have this open sorry, not main view controller. It's our main dot storyboard. If you don't have it open, simply click it. And I'm just using these buttons in the top right to move things out the way. So it's easy for us to see in the bottom. We need bottom, right? We need to find something that allows us to have a button, and surprisingly, this is called a button. So I'm gonna drag one over to my screen just in a random place, then in the right hand side inside my inspector. And this is the attributes, Inspector. I am going to change the name of it to one simply the number one, and I'm going to increase the font size of it, make it nice and big, and maybe we can have a background color for this. So if I scroll down, I'll see there's a background section and If I click it it, let's me choose a color. And I think I'll have a nice yellow color toe offset the blue. Okay, now we have a funky button. We can use these handles on it to resize it or down in the constraint section on pinning. We can actually specify a width and the height. So let's have this having a whip off 50 and a height off 50 apple Say all of your buttons should be at least 44 by 44 so fingers will be big enough to actually tap them. Hit. Add to constraints and that should do it. The next thing we need to do is position this relative to the display of our calculator. So what we do is we're going to hit control, hold it down, click on one, and then we can drag up to display, and it will give us a bunch of options when we let go. So what we want to have here, I think, is the vertical spacing. And when we click this blue line, that appears we now have an option over on the right to change this, we can change it to whatever we like. So let's have this set at 60. Then we also need a way to align this one in the horizontal axis. So we come to our very first problem. Ideally, we'd like our whole number pad to sit under the display and look great there. So everything's lined up horizontally, but one is just going to be slightly left off. Horizontal center. If you imagine a keypad, it goes 123456789 in three rows. So let's change this one. Actually the number five because that is the center off most keypads the number five. Then what we can do is place this five horizontally in the container to constrain it again . So, down on the bottom, horizontally in container, click it and click. Add one constraint. Now let's see what it looks like. If you click this triangle in the bottom and you update the frames, it moves everything to where you've specified. And now we have a nice five there. I'd actually like to move that down a little bit. So if I click the actual item itself and over on the left hand side, you'll notice we have some constraints here. So I have this display. And if you click through them or you actually read them, we can find this constraint here, which is the top of five is equal to display of calculator bottom plus 60. And we can change that over on the right so I can make that 100 drop it down a bit. Maybe 100 and 20 just to give us some space. Okay, that's how five button done. Now we need to add all the rest. And instead of recreating each button, what we can do is actually copy this one. Hold command, See? Click Somewhere in the view Controller and hit command fee. And there we have it. Now, this is also called five. And if we look at the constraints currently has the height and the width. So this button currently is just floating wherever we've put it. So what I'm going to do is build my key pad out from the center. I'm going to call this number two, and then I'm going to link this number two by holding control, clicking on it, clicking on five and putting some vertical spacing in. And then I'm going to change that vertical spacing. So over here, when I select it, I can come to the right. Andi, I can make this, Let's say 15. And then, of course, I can center this horizontally in my container. And then when I update everything there, we have it. So I'm just going to run through during all of this very quickly. And I want you to take your time in laying this keypad out. Think very carefully about constraints, because if you put one too many or one too few things often go wrong in this section, I'll join you in a second or so when all of my keys have bean laid out. And there she is. Now, my calculator should look more or less the same as yours. And when you click this triangle in the bottom and you actually say update which mine has already been updated, your elements should stay in the same place. When you click your assistant editor, it's going to pop up with the screen of your different devices and again on there. They should look like they're in the same place. If they're not, you need to go back into your editor and have a play with the constraints. If you have been struggling with this recall that we started with the number five, then what I did is I created the number two. I sent it it horizontally, and I put it 15 points above number five. I did the same thing with number eight, except I put it 15 points below number five. And then I kind of worked my way round each button that I wanted to place. And that's how we know they're all going to stay in the same place now. The next part of the exercise is to add in some plus minus times and divide buttons. So I'm going to copy my zero button. I'm going to paste it somewhere, and I'm going to call this obviously plus, and then I'll show you what I did before I roughly aligned it. I pasted another button and I'm gonna call you minus. So the minus one, I'm gonna control, click and drag over 20 put some horizontal spacing in, and then I'm going to click that horizontal spacing and set it to I think I'll make this about 24 and then I'm going to control click and drag to seven, set some vertical spacing and again click the little boom line that appears and I will set this to 24. Then I'm going to position my plus button relative to the minus button with some horizontal spacing, and I will set this at 15 like that, and then I need one final bit for my plus button. Hold control. Click and drop it to seven vertical spacing. I need 24 for that to match the minus button down in the bottom corner, I'm going toe update my frames, and there we have them kind of offset so that we know as the user they're they're far enough away from the buttons that we don't accidentally press them when we're entering a number, then we're going to do the same for times and divide over here. So I'm just going to do this quickly and go quiet when I do it so you can just watch and there we have it. Our keypad is now separate from the actual operator functions, but actually, I'm just going to change. This. Have made a slight mistake. Let's make that 15 and then to check everything fits we can hit our assistant editor, and it will show us what that looks like in all the screens. It only just fits in on the iPhone four inch, so we should be good to go. But of course, we can always adjust the constraints so it does actually fit in more. That sums up the display of our calculator and the creation of it. So by now you should be quite familiar with setting constraints, adding new elements to the screen and constraining them relative to each other as well. So you can kind of group them together. There are a lot more to constraints. So if you want to have a read, just jump onto Google and there are lots of YouTube videos you can reference here and there . But once you've got these basics, your set 4. 4: Brady. Let's crack on and connect all of these buttons of all calculator into our code. The first thing we have to do, of course, is open up our assistant editor, and I'm just going to make a little room here. And when we click those double rings, we have our main story board preview. If we click the preview icon Goto automatic and view Controller X Code knows which code file you should be linking to from your view. So it does it automatically. And hence that automatic button. Now in here, we have to start dragging various elements in. So first, we want the display over the calculator. If you hold control down and drag it over, we have the display and we will call this display label. You'll notice the first letter is lower case. The second letter of this, the first letter of the second word is upper case, and this is a convention we follow in programming. So just do all of yours that way, and we're going to connect that. Then, of course, I'm going to make a little room. We have to connect all of our buttons, so it's a little tedious, but It has to be done now because this is a button we need to do something slightly different here in this connection section at the top, we have some options, outlet action and outlet collection. The outlet is simply a link to the button. What we need is the action, and the action is simply a function that gets fired every time someone clicks the button. So if I click action and I call this button one click and under type, we want you, I button and the event is called Touch Up Inside. There are lots of different events we can use on I us for button clicks. I won't go into them. It's beyond the scope of this tutorial, but touch up inside is the classic button Click and then hit Connect, and then you'll notice it's actually made a function for us. So this whole section gets fired every time number one is pressed. We need to do the same for all the rest off the buttons, and we have to give them an appropriate name. So I'm just going to run through those quickly and come back to you in a second. And there we go I've added the mole, and that was quite tedious. As you go one through your development career, you'll find short cuts and ways to do these. And in fact, there are ways to add multiple buttons really quickly. But that's a much more advanced feature, and you won't need it that often unless you're making something like a calculator app. So I have all of these actions that get fired off whenever a button is clicked down here. So now we're done. We're almost done. No, in fact, we are done without display. The only thing left to do, I think, is double click the display of calculator and just put zero in it because that tells our user that nothing is currently happening to it. Okay, we can actually exit out now from the assistant editor, and we can go over to our view controller dot swift. That's the file that we just dumped all of the's codes into. We need to figure out a way toe, actually get the numbers from the buttons and apply them plus the minus the multiply the divide, etcetera, and then show that on our label, and that's exactly what we're going to cover in the next lesson, 5. 5: now it gets tricky before we just go plunging into code. We need to sit back and actually think about how people use a calculator. Typically, they don't want to know four times four or four times nine or nine times two they want to know 92 times 64 or 930 divided by five. So we've come to our first problem. How do we allow a user toe actually enter one number after another? Well, what we have to do is have another variable inside of our view controller dot swift that keeps track off whether or not the last button pressed was a number. Now, if the last button pressed was a number, and then you click another number that tells me that you want to keep entering a long number in the calculator. If you'd clicked a number and then clicked, multiply or add, I would set that variable to false telling me that the last number the last Button clicked wasn't a number, and that says, Okay, now you have to start performing an action. It's a bit of a tough thing to explain, so it's bet it's best if we actually performance. The fresh thing we're going to do has come down enough. You control adults swift and create a function number. Button clicked. And then inside here, we're going to pass it the number so we'll just say number. And this is going to be a type off int because all of the numbers on our calculator are whole numbers. So inter jizz is fine. Open our curly braces. When we hit Enter, another one is put there for us. So this function is going to get called every time we clicker number button and that means inside of these items here we have to call it so number button clicks and we're going to pass it the number one and you can see where this is going. It's just repetitive. Pass it the number two and in fact, you can copy and paste and change the number on the fly. Three. Be careful. You don't make an error here because you'll have to go through the code again if you do, and a five under six seven and we keep going and we have the last one, which is a zero. So every time we click one of the buttons. We're coming down to this method, and what I'm going to do is put a comment up here just to say what it is because there's already a lot of code building up here. So we've got to make sure we don't get lost if we come to change it in the future. So I'll just type function fires after number Button clicked like So Okay, so whenever we use our calculator and we hit a button, we would like to see that number appear on our display. And in our case, that's the label that we defined up here as the outlet, the display label. So what I'm going to do is, say, display label don't text is equal to the number. Now let's see if this gives us an era and there we have it. And if we click the error, it says you can't use an integer as a string. So what you can do to fix that and lots of languages do this. They allow you to cast from one variable type to another, so if you have an integer, you can change it to a string in the following way. Back at the beginning, type string and then put your number inside brackets so that converts this number into a string. Let's hit, play and run it on our simulator, and every time I click a button, you'll notice it changes to the display, and this is a good time to check. The right button is correct. Is connected to the right number. Okay, there's one thing missing from this, and actually, it's an equals button. I can't believe I've left that out. So let's come back to Ex Code. Open up our main story board and what I'm going to do is quickly add one. I'm going to copy that zero button, and I'm going to call it equals, and I'm going to change its width. So over here it's width is currently set at 50. It needs to be wider than that. Let's try 100. Let's try 1 40 and then it needs some constraints, of course. So going to put some vertical spacing and click it. Let's have this 20 and I'm going to put its center inside the screen. Okay, let's just check what that looks like. Okay, that's fine. So of course I need to drag. That equals button in to my assistant editor Over here. Old control. Click and drank. And we will call this an action that passes au I button and equals Button clicked. I can't believe I forgot that, but you'll find us a lot in programming. You'll forget really simple things and have to go back on yourself. So let's go back over to our view controller and there we have it. Okay, So where were we before? We were over in our simulator and our buttons allowed us to enter number. The next part of this AP is to actually allow us to enter a longer number than one digit. 6. 6: in this lecture, we are going to look at adding extra numbers to this display, and the way we do that is over in X code. I'm just going to hit. Stop in view controller dot swift. Inside our number button clicked. We need a check to see if the last button that was clicked was a number, and if it waas allow us toe, actually click another number. So let's create a variable. It's going to keep track of that. This variable is going to be what's called a boolean, and a Boolean variable type simply keeps hold of true or false yes or No. 100 We will call this far last press number and will explicitly say This is a boo will make its very first value as true. So equals true when our app first fires up, it makes this true, and that's because we haven't pressed anything yet. So, technically, we want to press some numbers before we actually do the procedure off multiplication or addition. So up in our function, off number button clicked. Let's make a little room around what's here and when the number button has been clicked, you need to perform some clever ideas here, so we have to check if the last press number is some kind of condition, like true or false. The way we do that is by using an if statement if and then in brackets, you have to give it a condition that it can check on the way we do. That is by saying last press number, and if we leave this as it is and we just closed the bracket, then what it's going to do is check. If the last press number is true, we could technically also say equals equals. True, it's the same thing, but we're not going to do that. We're going to use this short cut off the last press number. If I wanted to check. If last press number was false, I would put an exclamation mark in front of it. So we want to check if last press number is true and after every if statement, we need our curly braces that allow us to execute something if the statement is true. So if the last number pressed is true, what we want to do is actually add to the display label doc text. So let's hit display label. Dark text is equal to the display label dot text, plus the string conversion off our number like that. This is going to give me an era, and it says Value of optional type string not unwrapped. Did you mean to use exclamation or question? Simply click, fix it and insert the exclamation. Optional types are a bit more of an advanced topic in the swift language, and they're a bit tricky to get your head around. But for now, let's just fix it with X codes. Suggestion. What I'm going to do down here is just remove this line so it doesn't fire. And so in here, if the last press number, it's true and display label doc text is equal to the current text, and then you're going toe. Add the number onto the end of that text. So plus, when you use it with strings, simply puts the strings together. It's got nothing to do with numbers and then down below, because we've actually clicked a number we want to set last press number equal to True. To indicate the last thing we clicked was a number. Let's hit, play and run that see what happens now? When I click a number, you'll notice it adds to the current number, but we have a problem. We started with his zero, but we didn't get rid off zero, which is a bit annoying. So let's come back to Ex Code and fix that over in our main dot storyboard. We can change that display to actually show nothing text wise. And so when you do that, it's always a good idea. May be to have a background that we can actually see that allows us to know there's a label there. So I'm just going to hit my background and change it ever so slightly something nice and light. And now if I hit play, I should be able to see it. But I don't have zero there anymore, and I can enter my numbers as and when I have to. Okay, And of course, I can still enter as many numbers as I like and scroll off the screen. That's fine. We'll let our users do that. Maybe I'll said that his homework to fix that right? So back in our view Control. Adopt Swift. We have a way to add numbers to our screen and a way to keep track off the last number that was actually clicked. Now what we have to also do is have a function that keeps track of whether we've clicked plus minus multiplying to fight. So let's call that function Teoh. Keep Trek Off multiplier or something like that. Let's type funk. Ah, and we will call this operator clicked. And then, of course, we have to pass it something to let us know which operator has Bean clicked will use a simple, simple string for that that we will call this operator. We can call it that. That's one thing to note if it puts things in a different color. You have to be very careful cause you might be overriding the names off other things that are around. So I'll just call this hope, and this is going to be a type of string. Oops, I've created a square bracket by accident. We want to curly brace. There we go. So now we have a function for our operator. Of course, we need to call it when we click our operator buttons so way at the top Inside button plus click. I'm going to call operator clicked, and I'm going to call this a plus, and I'm going to copy that and paste it in all the other functions. This one, of course, will be minus and multiply and, of course, divide. Now we need a variable to keep track off this operator that we've lost clicked. So down here under last press number, let's have var operator or O P er. Let's have that. And let's make this the type of string and leave it at that. Then inside the operator clicked function. We want to say the upper is equal to the Opie, the one we just passed in, so kind of passes it down over here than inside this function. We also want to set the last press of the number as false because we've just clicked an operator button, not a number button. So if you think about a calculator, you click a few buttons, you click times and then the next number button you press. You expect that to start a new number on your screen, and that's why we set the last press number equal to false. One final thing before this lecture ends is in this function off number button clicked. We have to have a function that checks if the last press number is false. So the way we do that in Swift and in most languages is we add to this if statement just under the curly brace type else, open your braces and close them. So this is your introduction to if else statements and you will use these so much in programming. The if statement checks for a condition. His last press number. Truth. If it's not true, it ignores everything here and immediately drops down toe else and runs everything inside here. So because we have a new display off numbers, we're going to say display label dot text is equal to you. The string of our number. So where is before we actually added on to the current text. This time we're replacing all the text without string number. So let's see if that works. I'm just gonna hit play. Oh, we have a little failure. Now when you get a failure in X code right at the top, hit the exclamation mark and when you scroll down, it says class view controller has no initialize is, and that is a strange era. We shouldn't have that. Let's just scroll down and see if I can spot what's gone wrong. It's probably something to do with this line. Far Opera String. I bet you if we set it to just a blank, the era will go away and over on the left. Our era has disappeared. So you have to be careful of things like that when you're programming, let's hit play And here we have it. Now I'm gonna hit my numbers like I did before. I'll press plus then on way to press another number and our display has been cleared. And every time I hit an operator function, the display clears, which is really, really good. It would be nice if we had a function to see what operator was currently active, but we're not gonna worry about that in this tutorial. Okay, so in this lesson, you've learned how to keep track of things within your code. Using Boolean, keep track of strings, past functions, toe other functions, and this is the core of programming. You'll be doing this a lot 7. 7: we're almost there. We have our calculator. We can hit a bunch of numbers, a multiplier and a bunch of numbers. But I've noticed an error. When I press equals, I get a zero. That shouldn't happen. So come over to X code and open up your main dot storyboard inside of you controller click equals and in the top right corner there's a little arrow that's called The Connections Inspector, and inside here it tells you exactly what that button is connected to in code elsewhere. And if I scroll down, it actually has two events connected to it. One is a butter not click, and one is an equals button click. Clearly, we don't want the butter not click. And that's happened because I copied butter. Not without thinking so. Always, always programs slowly. That's the lesson there. So delete that one the but not click by hitting the X. And now when I hit play, I shouldn't get that zero whenever I hit equals. Yeah, so it's fixed. That's just a side note for you. Come back to view controller dot swift and let's continue with our calculator. The first thing we need is a way to keep track off the numbers that have been entered. So the very first number that we enter in a calculator is followed by an operator plus minus etcetera. So the ideal time to store that number is when the operator is actually clicked. And we already have a function for that. If you recall. So what we need is a variable to store the current number inside the label. So far, number one or oh, any. It's actually quite bad practice to use the actual numbers rather than letters inside your variable names. And I will call this string a type of string, and we will set this as blank. And we need a far number to which is this string, and we'll set this as blank. So blank is just when I'm typing two quotes in a row. Okay, in operator clicked. What we have to do is store the last number as number one. So we're going to say number one is equal to display label dot text and they might be an error that pops up here. There it is. And is that era about optionals? So again, you have to uncertain exclamation mark at the end It's just a new way of thinking in programming that says, If there isn't actually any text, I want you to be very careful with this value, so I don't get a horrible crash. There's a lot more to it than that, but that's the basics of it. So every time we click, one of the operator buttons were going to store a number inside number one. And of course we have to do the same with number two. We only need to access number two whenever we press equals. So up here in equals, Button clicked. We're going to set it. We will say Number two is equal to the display label dot text. And don't forget your exclamation. Now, if you're new to programming, I've referenced number two up here yet. It's declared down here, and that's fine because programming doesn't work linearly like that, so you can actually do that. You can put things wherever you like wherever seems to make order to you as the program, so it's a bit of an art like that. Now we need a final if else check. So we're going to say if our operator is equals equals two and What have we got here? We've got Plus, then we're going to do something and we're going to say else if the operator is equal, equal to minus, we're going to do something else and we're going to continue copying this code and just modifying it slightly for each case. So we'll want to multiply case and we will want a divide case some skank tow line these up . So it's easy to read for us. We have lots of cases. So in each case were actually going toe put something out. The display text. We're gonna do a little some to give us the answer, then right at the end. Off this, we actually want to clear everything because we've already done out some. So we say Number one is equal to blank. Number two is equal to blank, and the operator is equal to blanks. That resets everything but still leaves the display on the screen as it is. And of course, we need to have the last press number as false because again, we're starting again inside our very first. If statement, let's say let answer equal to then we need the numbers that we have so We need an integer made out of number one because if you recall, it's stored as a string and we, of course, when we add strings, they just get, like, chocked on one onto another. But we need to change it toe a proper number, like an interview that allows us to do proper addition someone even exclamation at the end of that plus integer number two exclamation. Then we need to say display label don't text is equal to, and we need to convert the answer into a strength like so So that's just test that version out. Build a succeeded. And if I say 12 plus seven equals 19 it works for us. So let's stop that running. Let's do the same for minus. We shouldn't have a problem there, so I copied and pasted from Plus, and all I have to change is minus. Now multiply and divide might be a little more tricky. Let me hit, multiply and see what happens. Multiplying programming is actually star, so let's hit play. Come over here and say five times five equals 25. Not bad. Let's say 999 times. Another really big number equals Oh, we have an era, and we have lots of scary things going on here in X code, telling us what the error is. But in this case, the era is that the integer can only hold a certain size off number. So if we try anything fancy with that number and make it really big, the Inter jet will crash and you have to really watch out for this. And this is the reason we use other kinds of numbers, like floats, doubles and larger inter jizz. In fact, we can have inter jizz that are 64 bits long, which are massive numbers really, really big in front. Let's change these two int 60 fours. Let's see what happens if we run that and try a very big calculation again. So let's try that times that equals and the answer works so that previous error is actually called an overflow. We've run out of memory inside that interject, so just be careful of that in the future. Now, let's go ahead and divide. We're to copy that in 64 property into here and change this for a forward slash, which is divide or run that in the simulator now Let's try something simple. 10 Divided by two is five that works. What about 12? Divided by five? You might expect 2.4 when I hit equals, I only get to now if you recall an integer, whether it's 64 bit or not can only store ah whole number. So when it does this calculation, what it does is it drops the point, for it drops the remainder if you don't want it. To do that, you need to use a different kind off number. So as our final task, let's try that. I'm going to try and change this to a double. Not sure this is actually going toe work, but we can always try how I have two doubles. I have no errors. That's good. Now I'll hit play. Let's try 12 Divided by five equals 2.4, and that's because they double install decimals. Where is an integer cannot. So there we have it. Our app is more or less complete. I can keep drinks 78 minus seven 71 it will do one some at a time for us