I am trying to print my input from textfields I have setup to the console before I print them to a label. I've tried string interpolation and various other methods, but I can't seem to get it to print the inputs themselves. I know force unwrapping is frowned upon but I will handle it properly after I get this to work. I've checked other asks extensively but found nothing specific to this in particular
To be clearer, when I press submit I want the text from the textfields to print to the console. Right now what happens is the values only show up at (UITextfield)
class SPProfileViewController: UIViewController {
@IBOutlet weak var typeOfCompany: UITextField!
@IBOutlet weak var firstName: UITextField!
@IBOutlet weak var lastName: UITextField!
@IBOutlet weak var email: UITextField!
@IBOutlet weak var cellPhone: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
typeOfCompany.delegate = self
firstName.delegate = self
lastName.delegate = self
email.delegate = self
cellPhone.delegate = self
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
cellPhone.resignFirstResponder()
}
@IBAction func onSubmit(_ sender: UITextField) {
print(self.typeOfCompany.text!)
print(self.firstName.text!)
print(self.lastName.text!)
print(self.email.text!)
print(self.cellPhone.text!)
}
}
extension SPProfileViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
}