So I am developing this app, where there is a textfield, and when you write on it, it is taken to the next SecondviewController. However, if nothing is written on the textfield and you press "Done" button, it should give you an error.
For this I have made an IBOutlet for the NSTextField as this:
@IBOutlet var weblinklabel: NSTextField!
Then this 'done' button contains an IBFunction with the following if statement:
@IBAction func actionWeblinklabel(_ sender: Any) {
if weblinklabel != "" {
self.view.window?.close()
} else {
label1.isHidden = false
}
Whatever is written in webllinklabel
should be compared with an empty string, if weblinklabel
has something in it then it should just close the current viewController otherwise it should give me a label (label1).
When I do this, I get this error:
Binary operator '!=' cannot be applied to operands of type 'NSTextField!' and 'String'
What am I doing wrong with my code. Thanks in advance! :)
Aucun commentaire:
Enregistrer un commentaire