let string = "४"
let intParse1 = Int(string) //goes for nil, why? is there any pure solution in swift
let intParse2 = (string as NSString).integerValue //goes for 4
1 个答案:
答案 0 :(得分:4)
使用NumberFormatter
let numberFormat= NumberFormatter()
numberFormat.locale = Locale(identifier: "EN")
if let getOP = numberFormat.number(from: "४")
{
print("output is: ", getOP)
}