user6042346
user6042346

Reputation:

How to clear a UITextView with a UIButton

I am attempting to make a UIButton that will clear a UITextView that I have set for the output. When the user has seen what they want to see, they click OK and it clears it and they can start again. The code I have set up for it is this and I can not figure out why it will not work, I just click the button a hundred times and nothing happens.

@IBAction func okButton(sender: UIButton) {
    resultOutputLabel.text == ""
}

Upvotes: 0

Views: 40

Answers (1)

Mudith Chathuranga Silva
Mudith Chathuranga Silva

Reputation: 7434

Not == , you should use =

resultOutputLabel.text = ""

For assign a value you should use = sign, == use for comparison purpose. Such as

 let a = 5  
 let b = 5

if a == b {
   // a value = b value
 }

Upvotes: 1

Related Questions