Gagan_iOS
Gagan_iOS

Reputation: 4080

How to convert price in string into value in swift iOS SDK

Please guide me an issue, I am getting a price from the server as below (as an example)

two hundred forty-two

and I want to convert this value into 242.00.

Please guide me on how to convert it.

I know we can use .spellOut with NumberFormatter for converting value into String but can't find a way to do the above.

Upvotes: 1

Views: 216

Answers (1)

dalton_c
dalton_c

Reputation: 7170

Alright, you have managed to nerd-snipe me.

I've implemented a number string parser as a Swift package. I don't expect you to bring in a whole package just to do this, but you might find some inspiration here:

https://github.com/daltonclaybrook/NumberParser

Upvotes: 1

Related Questions