Small swift library to work with currencies in ISO-4217 format.
With this library you'll get a correct price currency formatting for any ISO-4217 currency code that is supported by Apple's Foundation.
For example, you got a server response like this:
{
"code": "EUR",
"value": 15
}
To achieve 15 €
representation, all you need is to write 2 lines of code:
if let price = Price(value: 15, isoCode: "EUR") {
print(price)
}
Or
let price = Price(value: 15, currency: .eur)
print(price)
Having an instance of Price
, you can get a nice string representation in a various ways:
print("\(price)")
let string = String(describing: price)
print(string)
print(price.format(minimumFractionDigits: 2, decimalSeparator: "."))
To run the example project, clone the repo, and run pod install
from the Example directory first.
iso4217 is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "iso4217"
iso4217 is available under the MIT license. See the LICENSE file for more info.