Post #1897045
2025-04-17 20:10 UTC
Recently, I was working with units and unit conversions in Swift. After a while, I then remembered that Swift has a built-in structure for doing this: `Measurement`. This is so good and so under-appreciated that I thought it deserved its own article: https://troz.net/post/2025/swift-measurements/
Replies (4)
-
@Drwave@mastodon.social 2025-04-17 20:17
@troz@mastodon.social It's available in Obj-C as well as NSMeasurement (it’s part of Foundation) - I've used it for a long time, and it's great!
-
@Drwave@mastodon.social 2025-04-17 20:18
@troz@mastodon.social as you say, it's especially useful for lengths, and also mass.
-
@MuseumShuffle@mastodon.social 2025-04-18 01:26
@troz@mastodon.social I did not know anything about this before I started making a weather app. It is so good!
-
@wigging@fosstodon.org 2025-04-18 14:29
@troz@mastodon.social There is also the Physical package by @hyperjeff@mastodon.social for working with units in Swift. https://github.com/hyperjeff/Physical