Ben
Ben

Reputation: 59

Check for changes in UITextField

I'm attempting to make an app that checks the text in a UITextField and does something in response to what is written in it. I could possibly have the user type their input and then press a button. I want to be able to check the text field constantly without the application becoming unresponsive.

Upvotes: 0

Views: 575

Answers (1)

Leo Dabus
Leo Dabus

Reputation: 236260

What you have to do is to attach an IBAction to your UITextField Sent Events Editing Changed:

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var strLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func editingChanged(sender: UITextField) {
        strLabel.text = sender.text
    }
}

enter image description here

enter image description here

Upvotes: 4

Related Questions