Hi guys,
I just started coding a couple years ago and couldn't find an answer to the following issue yet. The math calculator built works fine in EnglishUS/USA, EnglishCanada/Canada, EnglishUK/UK, EnglishAustralia/Astralia and other regions. However, it crashed if phone set for some european countries. Xcode Decimal pad is used for the calculator. I believe that the failure has to do with dot (.) or commas (,) used in many countries as decimal separtor. That's why I had included NumberFormatter method in my code from the very beginning. It still didn't resolve the issue. I assume I didn't apply NumberFormatter correctly. When the app crashes, it specifies the following error: "Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 20628_Portrait_iPhone-Simple-Pad_Default".
The code is as following bellow. Any help is appriciated.
import UIKit
class A_ViewController: UIViewController {
@IBOutlet weak var originalMWTextField: UITextField!
@IBOutlet weak var shutIDPPtextField: UITextField!
@IBOutlet weak var trueVDtextField: UITextField!
@IBOutlet weak var switchTapped: UISwitch!
@IBOutlet weak var outputTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func calculateTappedButton(_ sender: Any) {
let num = NumberFormatter()
let firstValue = Double(num.number(from:originalMWTextField.text!)!)
let secondValue = Double(num.number(from:shutIDPPtextField.text!)!)
let thirdValue = Double(num.number(from:trueVDtextField.text!)!)
if switchTapped.isOn {
let outputValue = secondValue * 19.23/thirdValue + firstValue
outputTextField.text = String(format:"%.2f ppg. Round up if required!", outputValue)
} else {
let outputValue = secondValue * 19.23/thirdValue * 3.281 + firstValue
outputTextField.text = String(format:"%.2f ppg. Round up if required!", outputValue)
}
}
@IBAction func gestureTapped(_ sender: Any) {
view.endEditing(true)
}
}