I created 2 UITextFields for the user to enter data (Int) into. I then want to create a var from the user input data to use in some equations. How do I go about recording the data that the user inputed into the blocks?
My code currently looks like this.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
}
@objc func dismissKeyboard() {
view.endEditing(true)
}
@IBAction func sMinInput(_ sender: UITextField) {
}
@IBAction func sMaxInput(_ sender: UITextField) {
}
2
Answers
This is working for me. The key is to set your
IBAction
using whichever "Sent Event" you’d like. I chose "Editing Changed". You can add as many UITextFields (or anything, really) you’d like. Good luck!You can capture input data in a UITextField using following method.
}