When the equals button is pressed in the calculator app, it should show the total—either the sum or the difference of the two numbers depending on what mode button was pressed. See how to set it up here.
- [Instructor] With everything else set up,…it's time to set up the Equals button…and begin wrapping up the calculator.…So find the method where we handled that,…which is called didPressEquals.…On my code it's on line 40.…I'm going to put my cursor in between the curly braces,…and what we're going to do is start with a guard statement.…What we want to do is make sure we can get…the value of the calculator in an integer.…So let's find that by going down to updateText,…and we're just going to copy this guard statement.…
Remember, all it does is it takes labelString…and converts it to an integer,…and holds it in this labelInt constant.…So select that, copy it with Cmd+c,…scroll up into didPressEquals,…and I'll paste it in there.…And now we have labelInt,…where we can access the value of labelString as an integer.…And then all we need to do…is just combine that with our savedNum.…So we add it to savedNum,…or we subtract it from savedNum,…and that is how we get the number inside of the calculator.…
Now, before we do that part,…
- 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.