Sorry if my question has a ridiculously simple answer, but I'm new at this, so I have no idea what to do.
I am making an app that tells you how much medicine an animal needs based on their weight, etc. For the LRS (a type of medicine), the formula is
30 * weight * factor + 70 * factor + dehydration + weight
So in my code, I typed
lrs24.text == 30 * &weight * &factor + 70 * &factor + &deh + &weight;
The compiler said that "Expression was too complex to be solved in reasonable time..." What does this mean, and how can I fix it? Maybe I just typed in some wrong code? Thanks!
PS- The compiler says to break up the expression into smaller sub-expressions, but I don't know how to do that :(
PPS- Here is my full code:
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var animalNum: UITextField!
@IBOutlet weak var logLabel: UILabel!
@IBOutlet weak var resetButton: UIButton!
@IBOutlet weak var weight: UITextField!
@IBOutlet weak var deh: UITextField!
@IBOutlet weak var losses: UITextField!
@IBOutlet var factor: [UITextField]!
@IBOutlet weak var lrs24: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Handle the text field’s user input through delegate callbacks.
animalNum.delegate = self
}
// MARK: UITextFieldDelegate
func textFieldShouldReturn(textField: UITextField) -> Bool {
// Hide the keyboard.
textField.resignFirstResponder()
return true
}
func textFieldDidEndEditing(textField: UITextField) {
logLabel.text = textField.text
}
// MARK: Actions
@IBAction func setDefaultLabelText(sender: UIButton) {
logLabel.text = "Default Text"
}
@IBAction func textFieldsDidEndEditing(sender: AnyObject) {
lrs24.text == (30 * weight + 70) * factor + weight * deh * 10 + losses;
}
}