Home > Mobile >  How to convert price in string into value in swift iOS SDK
How to convert price in string into value in swift iOS SDK

Time:12-26

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.

CodePudding user response:

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

  • Related