I can not find the solution that works for me.
@IBOutlet weak var N1: UITextField!
@IBOutlet weak var N2: UITextField!
@IBOutlet weak var P1: UITextField!
@IBOutlet weak var P2: UITextField!
@IBOutlet weak var F1: UILabel!
@IBOutlet weak var F2: UILabel!
@IBOutlet weak var res1: 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 total(_ sender: Any) {
let n1 = Double(N1.text!)
let p1 = Double(P1.text!)
let f1 = Double(n1! + p1!)
F1.text = "\(f1)"
let n2 = Double(N2.text!)
let p2 = Double(P2.text!)
let f2 = Double(n2! + p2!)
F2.text = "\(f2)"
res1.text = "\(res1)"
How can I do to take the results that I get in Label ( F1.text
/ F2.text
) and add them again, appearing in another Label ( res1
)? (All by clicking the same button)
idea:
2+2=4
1+2=3
4+3=7