# iOS 10 Screencast: Measurement Formatter

**URL:** <https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289>\
**Category:** 🎓 Courses & Articles\
**Created:** [August 9, 2016, 2:37pm UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289 "2016-08-09T14:37:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [August 9, 2016, 2:37pm UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/1 "2016-08-09T14:37:29Z")

</div>

Formatting measurements for every language and country is hard, so Foundation includes a new MeasurementFormatter class. See how easy it is to use in the screencast.

 
* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/4953-ios-10-measurement-formatter](https://www.raywenderlich.com/4953-ios-10-measurement-formatter)

---

<div class="post-metadata">

**Author:** ![keith27](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/keith27/32/105896_2.png) [@keith27](https://forums.kodeco.com/u/keith27)\
**Post date:** [August 9, 2016, 8:24pm UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/2 "2016-08-09T20:24:14Z")

</div>

Genius, Sam, thank you!

But now, could you please explain what “covariance” means because each time I’ve tried to read up about it in different contexts, I’ve finished as baffled as when I began.

---

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [August 9, 2016, 9:08pm UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/3 "2016-08-09T21:08:02Z")

</div>

Thanks @keith27

Covariance is one of those terms that’s overly confusing, and people who like to wang on about Swift like to shout about a lot.

At its simplest, it’s not that difficult to understand. Covariance describes a situation where you can treat a subtype as if it were one of its supertypes. For example, when you override a method or property in a subclass then its return type is covariant - you’re allowed to return a subtype of the original return type in the overridden method.

The problem comes in the fact that in Swift, generic are invariant by default. That means that in this case although `UnitTemperature` is a subtype of `Unit`, `Measurement<UnitTemperature>` cannot be used in place of `Measurement<Unit>`.

I hope that goes a little way to explaining it. For more details, and a far better explanation, check out Mike Ash’s Friday Q&A on the topic:

[https://www.mikeash.com/pyblog/friday-qa-2015-11-20-covariance-and-contravariance.html](https://www.mikeash.com/pyblog/friday-qa-2015-11-20-covariance-and-contravariance.html)

sam

---

<div class="post-metadata">

**Author:** ![keith27](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/keith27/32/105896_2.png) [@keith27](https://forums.kodeco.com/u/keith27)\
**Post date:** [August 10, 2016, 8:11am UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/4 "2016-08-10T08:11:39Z")

</div>

Thanks Sam, that was a very helpful explanation and link.

---

<div class="post-metadata">

**Author:** ![d\_williams](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/d_williams/32/88476_2.png) [@d\_williams](https://forums.kodeco.com/u/d_williams)\
**Post date:** [September 20, 2016, 2:00am UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/5 "2016-09-20T02:00:11Z")

</div>

@samdavies this was funny and informative. I have a better understanding of MeasurementFormatter class. Thank you.

---

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [September 20, 2016, 6:44am UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/6 "2016-09-20T06:44:18Z")

</div>

@d_williams - glad you enjoyed it 🙂

---

<div class="post-metadata">

**Author:** ![gargoyle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gargoyle/32/107285_2.png) [@gargoyle](https://forums.kodeco.com/u/gargoyle)\
**Post date:** [September 23, 2016, 3:47pm UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/7 "2016-09-23T15:47:41Z")

</div>

What about height and weight for people? I’m not finding the equivalent of isForPersonHeightUse and isForPersonMassUse

---

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [September 23, 2016, 5:23pm UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/8 "2016-09-23T17:23:49Z")

</div>

@gargoyle

As far as I’m aware, `MeasurementFormatter` doesn’t support this, so you might have to resort to `MassFormatter` and `LengthFormatter` for the time being. Probably worth filing a bug report to get those properties transitioned in the same way that the temperature is supported without a unit.

sam

---

<div class="post-metadata">

**Author:** ![gargoyle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gargoyle/32/107285_2.png) [@gargoyle](https://forums.kodeco.com/u/gargoyle)\
**Post date:** [September 23, 2016, 5:36pm UTC](https://forums.kodeco.com/t/ios-10-screencast-measurement-formatter/18289/9 "2016-09-23T17:36:29Z")

</div>

Bug 28450109 filed. Everyone else go file the same bug now so they fix it 😉
