The add and subtract buttons of the calculator are vital to the calculator functioning properly. See how to create the logic for those buttons in this video.
- [Narrator] The next buttons that we're going to…handle are the add and subtract buttons.…And we have didPressPlus and didPressSubtract…to handle these methods, so let's go inside of them.…So we'll go inside of didPressPlus and then…in here I'm going to change the mode.…So I'll call change mode and I need to pass…in the new mode, which is going to be addition.…So just .addition, close out the parentheses with…a right arrow key press, that's it for that one.…Inside didPressSubtract, we're going to do the same thing.…Change mode, then we're going to change…this to subtraction, so .subtraction, another…right arrow key to close out the parentheses.…
Now let's go over to change mode and actually…define what that method does, that's…at the bottom of our code here.…And we have the new mode that comes in as…a parameter so that's either going…to be addition or subtraction.…So in here I'm going to set currentMode…equal to the newMode so if they press…the plus button it's going to change currentMode…to be addition, if they press the minus…
- Installing Xcode
- Creating an Xcode project
- Configuring the iOS Simulator
- Understanding variables
- Connecting visual objects to variables
- Understanding methods
- Connecting a button to a method
- Using conditional statements
- Setting up the user interface (UI)
- Building a complete iOS app
Skill Level Beginner
1. Set Up Your Coding Environment
Create an Xcode project4m 19s
2. Programming Building Blocks: Variables
3. Programming Building Blocks: Methods
4. Programming Building Blocks: Conditional Statements
5. Plan and Prepare the App
6. Build a Full Application
Next steps3m 11s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.