From the course: Cocoa with Swift 3 Essential Training

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Number formatters

Number formatters

- [Instructor] Let's say you're working with text fields or labels, and you want to format the number as maybe a date or a float value, or some other format that you'd like to use. Maybe you're going to display currency in your application, and you want to make sure that it's formatted properly and localized. So, to do that, let's drag out a few labels onto the screen. Let's say the top label is going to represent a date. And let's just expand it the whole width of the window right there. And then the bottom label is going to represent currency, and that's going to be a float value. So, date at the top, currency at the bottom. Let's option click AppDelegate.swift, and hook these up to our code. So, I'll hide the side areas here. And then I'm just going to right click and drag as usual, from the top label, right between lines 12 and 13, call this dateLabel, hit connect, same thing for the bottom label. Right click and drag in, call this currency label, hit connect. Now, we need to…

Contents