Swift Ruby
Switch branches/tags
Nothing to show
Latest commit 5cc805a Apr 19, 2017 @floriankrueger 🔖 Version 0.1.1
Permalink
Failed to load latest commit information.
Configs
Sources 🤔 Remove BasedDimension Protocol? Apr 13, 2017
Standards.xcodeproj
Tests
.gitignore
LICENSE
Package.swift
README.md
Standards.podspec

README.md

GitHub release Carthage compatible CocoaPods Swift GitHub license Gitmoji HelpWanted

Standards

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.

Compatibility

  • iOS 8.0
  • tvOS 9.0
  • watchOS 2.0
  • macOS 10.10

Features

Compared to Measurement, Standards has the following features:

  • Creating and Converting Standards (e.g. kilometers to miles)
  • Calculate with Standards (Operators +, -, *, /)
  • Compare Standards
  • Measurement Formatting

Compared to Measurement, Standards supports the following Units:

Remarks

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.

Basic Usage

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 

Installation

As for now, you can use Carthage or CocoaPods to install Standards using a dependency manager or do it manually.

Carthage

To integrate Standards into your Xcode project using Carthage, specify it in your Cartfile:

github "floriankrueger/Standards"

CocoaPods

Make sure your Podfile contains all of the following lines.

use_frameworks!
platform :ios, '8.0'
 
pod 'Standards'

Then run pod install.

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

License

Standards is released under the MIT License.