Join Todd Perkins for an in-depth discussion in this video Formatting the number with commas, part of Programming for Non-Programmers with iOS 8.
- Now the Calculator works as expected at this point,…but if you type a lot of numbers in, you won't see any…commas to separate the numbers out.…Of course, commas are what are used in the United States…and many other countries to separate numeric values.…Other countries use different methods, like dots.…To format, intelligently based on the location of the…device being used, you can use something…called the NSNumberFormatter.…We're going to look at how to use that in this movie.…I'll stop the app and go inside of the tappedNumber…method in ViewController.swift.…
To format a number in Swift,…there are a few steps.…We have to create a NumberFormatter,…set the number style for the formatter,…create a type of number that can be formatted,…and then format the number to a String.…So there are four steps…and four lines of code that go with that.…Right under line 42 in my code where we set valueString…inside of the tappedNumber method,…we're going to go down a few lines and create…a variable called formatter.…
This is going to be of the type NSNumberFormatter,…
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 method
- 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 project3m 38s
2. Programming Building Blocks: Variables
3. Programming Building Blocks: Functions
4. Programming Building Blocks: Conditional Statements
Using conditional statements4m 11s
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.