I am very new to all this. What I wanted:
I wanted this textfield (where there is "I am the placeholder") to allow users to type any string:
At the moment this textfield does not let me type in anything. It sits like a stone. There are no corresponding errors to this but this behaviour is not my liking. I wanted it to let me just type string.
Could anyone kindly point me in the right direction?
This is how IBOutlet connection made to the TextField in question
And the code snippet
class ViewController: UIViewController {
@IBOutlet weak var companyTextField2: UITextField!
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
private var models = [Consulting]()
//more other codes
@IBAction func insertName(_ sender: UITextField) {
// Create the UITextField
let nameTextField = UITextField()
nameTextField.placeholder = "Enter Name"
// Option 1: Add the UITextField to the view (if needed)
view.addSubview(nameTextField)
// Option 2: Use the UITextField (e.g., get or set its text)
let enteredName = nameTextField.text
print("Entered Name:", enteredName ?? "")
}
}