Large numbers don't automatically get formatted with commas or other characters depending on locale. This video shows how to set up that formatting.
- [Instructor] You may have noticed in our calculator,…if you start typing a lot of numbers, there's no separator;…in the US, that would be a comma;…in other locales, you might see a point there instead…to separate three numbers at a time.…So how do we apply that formatting to numbers?…Stop the app, and return to Xcode,…and then I'm going to find the method, updateText().…In here we're going to format the text…using an object called a NumberFormatter.…Earlier in the course I mentioned that there are more…complex types of objects than just strings and integers.…
You've seen a few already when we created our enum.…You've seen a UI label and some other objects as well.…The NumberFormatter is another type of object…that you can apply and use to format numbers.…So, inside of updateText(), underneath the if statement,…I'm going to create a formatter,…and I'm going to make it a constant.…So, let formatter.…Datatype is going to be a NumberFormatter,…and I'll set it equal to a NumberFormatter…and some parentheses.…
Now, this line of code right here is a special method.…
- 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?
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.