我有一个UITextField,大多数用户都有iPhone中的阿拉伯语和英语键盘,所以我的问题是当我在文本字段中键入阿拉伯数字时应用程序崩溃但是当我输入英文数字时一切正常!
任何帮助请...
我的代码:
var ourArray = [Int]()
var forThemArray = [Int]()
@IBOutlet weak var ourTextField: UITextField!
@IBOutlet weak var forThemTextField: UITextField!
@IBAction func record(_ sender: Any) {
if ourTextField.hasText == true {
ourArray.append(Int(ourTextField.text!)!)
}else{
let error = UIAlertController(title: "تنبيه !", message: "الرجاء تعبئة الحقول ثم اضغط سجل", preferredStyle: .alert)
let dismiss = UIAlertAction(title: "موافق", style: .default, handler: nil)
error.addAction(dismiss)
present(error, animated: true, completion: nil)
return
}
if forThemTextField.hasText == true {
forThemArray.append(Int(forThemTextField.text!)!)
}else{
let error = UIAlertController(title: "تنبيه !", message: "الرجاء تعبئة الحقول ثم اضغط سجل", preferredStyle: .alert)
let dismiss = UIAlertAction(title: "موافق", style: .default, handler: nil)
error.addAction(dismiss)
present(error, animated: true, completion: nil)
return
}
//remove the textField input
ourTextField.text = ""
forThemTextField.text = ""
print("Our array is : \(ourArray)")
print("for them array is : \(forThemArray)")
tableview.reloadData()
count()
self.view.endEditing(true)
updateImage()
}