From the course: iOS Development Tips

Unlock this course with a free trial

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

Basic measurements

Basic measurements

- [Instructor] If you've ever had to work with measurements, they can get out of hand quickly. Converting and formatting units from multiple locales can be a nightmare. Foundation provides a solution to these problems. The measurement class. Instantiating a measurement takes two parameters, a value and a unit. The unit abstract class has sub-classes for every kind of measurement you might think of. Type in unit in the playground and Command/Control click on it. And you get to the definitions. And we can look up here at the index of the definitions here and you can see there are a lot of them. Now we're going to spend most of our time talking about length and you can see there's an awful lot about length. Each one of these has a class. In this case, the UnitLength class that will now have all of these within it. So let's go ahead and close that back up and go back to the playground and give this a shot. So I'm going to…

Contents