TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Aug 2017 |
SwiftSwift Version | 3.1 |
SPMSupports SPM | ✓ |
Maintained by Florian Krüger.
Standards was created to enable iOS, tvOS, watchOS and macOS developers that need to support legacy systems (pre iOS 10.0, pre tvOS 10.0, pre watchOS 3.0 and pre macOS 10.12) to use the Measurement API that’s included in these systems’s Foundation.
Compared to Measurement, Standards has the following features:
Compared to Measurement, Standards supports the following Units:
Standards is designed to be API-compatible with Foundation on the call site. So you can just use it like you would use Measurement, with one exception:
For compatibility reasons with iOS 10.0+, tvOS 10.0+, watchOS 3.0+ and macOS 10.12+ it’s impractical
to actually call the class Measurement
(b/c you then would always have to namespace it). So just
replace Measurement
with Standard
.
let distance = Standard(value: 106.4, unit: UnitLength.kilometers)
// → 106.4 km
let distanceInMeters = distance.converted(to: .meters)
// → 106400 m
let distanceInMiles = distance.converted(to: .miles)
// → 66.1140591795394 mi
let distanceInFurlongs = distance.converted(to: .furlongs)
// → 528.911158832419 fur
As for now, you can use Carthage or CocoaPods to install Standards using a dependency manager or do it manually.
To do it 'by hand' take the following files and add them to your project:
Sources/Standard.swift
Sources/Unit/BasedDimension.swift
Sources/Unit/Dimension.swift
Sources/Unit/Unit.swift
Sources/Conversion/UnitConverter.swift
Sources/Conversion/UnitConverterLinear.swift
And any of the Units that you need:
Sources/Unit/UnitLength.swift
Sources/Unit/UnitArea.swift
Sources/Unit/UnitSpeed.swift
Sources/Unit/UnitTemperature.swift
Thanks for contributing to this project!
Standards is released under the MIT License.