Join Todd Perkins for an in-depth discussion in this video Making the Clear button clear all values, part of Programming for Non-Programmers: iOS 7.
- View Offline
- Exercise Files
…With the number buttons working, let's make…the clear button do what it's supposed to.…Find the tapped clear function, mine is on line 30,…and then we're going to reset all of our values here.…That means we're going to set total equal to 0, we're…going to set value string equal to an empty string,…And then we'll make the text label show 0.…Now here, we can use 0 as a string because we don't…care what the other values are because we're resetting them right here.…
So we don't need to go through the…extra effort of using NS string, string with format.…So let's test the application,…so I'll type some numbers.…Click the C button.…And the calculator clears.…Everything works as expected.…So again, to clear the calculator we simply reset all…these values back to where they were when we started.…
If you find you'd like to learn more, see iOS App Development Essential Training, Foundations of Programming: Fundamentals, or any of the other programming courses in our library.
- Installing Xcode
- Creating an Xcode project
- Configuring the iOS Simulator
- Understanding variables
- Connecting visual objects to variables
- Understanding functions, methods, and selectors
- Connecting a button to a function
- Using conditional statements
- Setting up the user interface
- Connecting code elements to build an app
Skill Level Beginner
1. Setting Up Your Coding Environment
Creating an Xcode project1m 55s
2. Programming Building Blocks: Variables
3. Programming Building Blocks: Functions
4. Programming Building Blocks: Conditional Statements
Using conditional statements5m 21s
5. Building Your First Full Application
- 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.