I have an english string that may or may not have numbers. But i want those numbers to be printed on screen as Persian numbers.
For example if NSString *foo =
convert number to any locale
let formatter = NumberFormatter()
formatter.locale = Locale(identifier: "ar")
if let localized = formatter.string(from: NSNumber(value: comp.0)) {
return "\(localized)"
}
example:
(lldb) po formatter.string(from: NSNumber(value: 0)) ▿ Optional - some : "٠"
(lldb) po formatter.string(from: NSNumber(value: 1)) ▿ Optional - some : "١"
(lldb) po formatter.string(from: NSNumber(value: 2)) ▿ Optional - some : "٢"
(lldb) po formatter.string(from: NSNumber(value: 3)) ▿ Optional - some : "٣"
(lldb) po formatter.string(from: NSNumber(value: 4)) ▿ Optional - some : "٤"
(lldb) po formatter.string(from: NSNumber(value: 5)) ▿ Optional - some : "٥"
(lldb) po formatter.string(from: NSNumber(value: 6)) ▿ Optional - some : "٦"
(lldb) po formatter.string(from: NSNumber(value: 7)) ▿ Optional - some : "٧"
(lldb) po formatter.string(from: NSNumber(value: 8)) ▿ Optional - some : "٨"
(lldb) po formatter.string(from: NSNumber(value: 9)) ▿ Optional - some : "٩"
(lldb) po formatter.string(from: NSNumber(value: 10)) ▿ Optional - some : "١٠"