Join Todd Perkins for an in-depth discussion in this video Formatting a number with commas, part of Programming for Non-Programmers with iOS 7.
…At this point, our calculator works fine.…And this would actually be a just fine place to stop.…But one thing you might want to know how to do…is to add commas to the number to format it.…I'm used to looking at numbers with commas every three digits.…So, let's look at how to do that in our application.…Or click the stop button and we'll go to our code.…Go to tapped number and right below where we set the value of value…string, which in my code is on line 49, again yours might be different.…
I'm going to go to the next line by creating a new line.…And then we're going to creat something called a NS Number Formatter.…That's a special type of object that enables us to add…commas to numbers and format numbers in other ways as well.…So I'm going to type NSNumberFormatter, this is, that's my variable data…type, and then an asterisk, because this is not a primitive data type.…And we'll call this Formatter.…I'm going to set that equal to, in brackets, NSNumberFormatter new.…
This line of code creates a new NSNumber formatter.…
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?
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.