3

I want converting int number in to letter of this number .I Have one text field .in this text field user can write number then i want convertin this number to letter . for example i want convert 11 to eleven .how can i do this work in swift .

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Hadiseh
  • 87
  • 3
  • 9
  • 2
    Hi Hadiseh, welcome to the site. Read the documentation of [`NumberFormatter`](https://developer.apple.com/documentation/foundation/numberformatter), it does what you're looking for, with `numberStyle` set to `.spellOut` – Alexander Dec 19 '19 at 15:13
  • the opposite direction https://stackoverflow.com/a/46856525/2303865 – Leo Dabus Dec 19 '19 at 16:29

1 Answers1

8

You can use like this :

let formatter = NumberFormatter()
formatter.numberStyle = .spellOut
let english = formatter.string(from: 1)

and you can Refer this Awesome Answer for objective-c.

If you wanted to get that in Espanol , you would set a locale like this:

formatter.locale = Locale(identifier: "es_ES")
let spanish = formatter.string(from:1)
Dhaval Raval
  • 594
  • 2
  • 7