I am wanting to take these textfields and preform an equation between them. What I am having trouble with is automatically updating the final textfield after my equation is done
In this scenario, I want the Total Cash Price to be updated when the Vehicle Price is updated or the Service Contract is updated without having to press the DP Button.
Can someone give me a suggestion on how to accomplish this.
Code:
@IBAction func DPButtonPressed(_ sender: Any) {
totalCashPrice.integerValue = vehiclePrice.integerValue + serviceContract.integerValue + salesTax.integerValue
}
Instead of it being @IBOutlet func DPButtonPressed(_sender: Any)
, i want that function to be automatically done.
This is where i am stuck at with using the delegate
override func viewDidLoad() {
super.viewDidLoad()
totalCashPrice.delegate = self
}
func textFieldDidBeginEditing(textField: NSTextField!) {
}
func textFieldShouldEndEditing(textField: NSTextField!) -> Bool {
return false
}
func textFieldShouldReturn(textField: NSTextField!) -> Bool {
totalCashPrice.resignFirstResponder()
return true
}
@IBAction func DPButtonPressed(_ sender: Any) {
totalCashPrice.integerValue = vehiclePrice.integerValue +
serviceContract.integerValue + salesTax.integerValue
textFieldShouldEndEditing(textField: totalCashPrice)