Swiftpack.co - zonble/HumanMeasurementSwift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by zonble.
zonble/HumanMeasurementSwift 0.1.0
Synatax sugar for Measurement of Foundation.
⭐️ 7
🕓 2 years ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/zonble/HumanMeasurementSwift.git", from: "0.1.0")

HumanMeasurement

2022 © Weizhong Yang a.k.a zonble

Syntax sugar for NSMeasurement of Foundation.

NSMeasurement and NSUnit compose a great tool to let you do unit conversion easily when you are coding with Swift. You can use them to convert length, temperature, mass, speed and so on. However, you want the API design to be easier.

For example, if you want to convert a temperature from Celsius to Fahrenheit, your code using NSMeasurement looks like:

let celsius = 25.0
let fahrenheit = Measurement<UnitTemperature>(value: celsius, unit: .celsius).converted(to: .fahrenheit).value

The package helps you to code like:

let celsius = 25.0
let fahrenheit = Temperature(celsius: celsius).fahrenheit

Installation

You can install the package using Swift package manager. Add the following lines to your Packages.swift file:

dependencies: [
    .package(url: "https://github.com/zonble/HumanMeasurement.git"),
],

GitHub

link
Stars: 7
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics