When a numeric button is pressed, it should show up in the calculator. This video explains how to do that, and some issues that arise when trying to put numbers there.
- [Teacher] The next step in our Calculator…is to get the numbers that the user taps on…into that label at the top of the screen.…Now, there are a few challenges in this.…The first one is that if the user taps a one…and then taps a two,…we don't want the Calculator to change…from one to two,…we want to show the number 12.…The second challenge that we have is…if the user presses a whole bunch of zeros in a row…before any other numbers,…we don't want it to be a whole bunch of zeros;…we want there to be just one zero.…
So let's look at tackling those problems.…Let's scroll down to didPressNumber,…and in here, the first thing that we need to do…is get the string value that's inside of the label…on each button.…Remember, each button has a label inside…with its number on it,…so if they press seven,…we want to be able to extract that seven.…Let's go to ViewController.swift…and go inside didPressNumber.…Now, in here, I'm going to create a constant,…so let and the space,…and I'm going to call this stringValue,…that's the string value of the button that was pressed,…
- 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.