Join Todd Perkins for an in-depth discussion in this video Displaying tapped numbers in the calculator, part of Programming for Non-Programmers: iOS 7.
- View Offline
- Exercise Files
…With our code connected to our storyboard assets, we're…ready to start writing the real code for our application.…In viewController.m, find the viewDidLoad function…and right below the comment we're going to initialize valueString by setting it's…value equal to an empty NSString, that is, at symbol and then two quotes.…Now before, we talked about integer variables and primitives, and how they…have default values, like the default value for a Boolean is no, or false.…
The default value for a number is zero.…Strings do not have a default value.…So, when we're working with the string…variable, we have to initialize it to something.…So, this us giving valueString a blank string.…Now, let's scroll down into tappedNumber.…In here, what we're going to do, is create an integer…variable to capture the tag of the button that was pressed.…So, create an integer variable.…We'll call this num and we'll set it equal to btn.…
That's the button, whatever button that…was tapped that triggered this function, .tag.…That's how we grab the buttons tag.…
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.