A big n00b here :-)
I made my first app for IOS and got everything working as long as all text fields are filled. This app is a simple calculation app and I need some help making sure that the app does not close down when fields are empty.
This is my code when a simple Calculation button is pressed.
class ViewController: UIViewController {
@IBOutlet weak var panelWidthTextField: UITextField!
@IBOutlet weak var panelHightTextField: UITextField!
@IBOutlet weak var panelsWideTextField: UITextField!
@IBOutlet weak var panelsHightTextField: UITextField!
@IBOutlet weak var panelPitchTextField: UITextField!
@IBOutlet weak var resultWithLabel: UILabel!
@IBOutlet weak var resultHightLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func calculatePressButton(sender: AnyObject) {
let w = Double(panelWidthTextField.text!)
let sw = Double(panelsWideTextField.text!)
let pi = Double(panelPitchTextField.text!)
let sizew = SizeWidthModel(pw:w!,psw:sw!,ptc:pi!)
resultWithLabel.text=String(sizew.width())
let h = Double(panelHightTextField.text!)
let sh = Double(panelsHightTextField.text!)
let sizeh = SizeHightModel(ph:h!,psh:sh!,ptc:pi!)
resultHightLabel.text=String(sizeh.hight())
}
}
This is my problem.
Hope someone can point me in the right direction.
Edit: As I am a complete n00b at this coding I need som more help understanding this. I have tried adding various solution with no luck. I am trying to get a message to pop up when user leave fields empty, because the calculation need all fields filled in. If someone have time to guide me that would be appreciated :-)