Ich weiß, dass es bereits einige Antworten gibt, aber keine von ihnen scheint mein Problem zu lösen, da sie über Variablen oder Konstanten in anderen Klassen sprechen, aber meine ist nicht t.Verwendung von nicht aufgelösten Bezeichnern, Teil einer einzelnen Klasse
Hier ist meine viewcontroller.swift (ich habe keinen Code in anderen Dateien gemacht)
class ViewController: UIViewController, UITextFieldDelegate {
// MARK: Properties
@IBOutlet weak var textFieldA: UITextField!
@IBOutlet weak var textFieldB: UITextField!
@IBOutlet weak var textFieldC: UITextField!
@IBOutlet weak var answerLabel: UILabel!
@IBOutlet weak var answerLabelNegative: UILabel!
@IBOutlet weak var whatEquation: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
textFieldA.delegate = self
textFieldB.delegate = self
textFieldC.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: UITextFieldDelegate
func textFieldShouldReturn(textField: UITextField) -> Bool {
// Hide the keyboard.
textFieldA.resignFirstResponder()
textFieldB.resignFirstResponder()
textFieldC.resignFirstResponder()
return true
}
// MARK: Actions
@IBAction func solveButton(sender: AnyObject) {
let a:Double! = Double(textFieldA.text!) // textfieldA is UITextField
let b:Double! = Double(textFieldB.text!) // textfieldB is UITextField
let c:Double! = Double(textFieldC.text!) // textFieldC is UITextField
let z: Double = (b * b) + 4 * a * c
answerLabel.text = "Positive equation x = \(-b + (sqrt(z)/2 * a))"
answerLabelNegative.text = "Negative equation x = \(-b - (sqrt(z)/2 * a))"
// These conditional statements are used to determine whether a + or a - should be infron of th number
if a < 0 {
let aValue: String = "-"
} else {
let aValue: String = " "
}
if b < 0 {
let bValue: String = "-"
} else {
let bValue: String = " "
}
if c < 0 {
let cValue: String = "-"
} else {
let cValue: String = " "
}
whatEquation.text = "\(aValue)\(a) \(bValue)\(b) \(cValue)\(c)" //This is where the error occurs, on the "whatEquation.text" line
}
}
'self.whatEquation.text' vielleicht? – Dershowitz123