0
Swift 4 Help Needed
I'm creating the ToDo List app on Swift fundamentals this is the viewcontroller.swift code that is supposed to be a method to determine whether the "Save" button on my app has been tapped and then creates the appropriate item object: override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if sender as AnyObject? === saveButton { let name = nameTextField.text ?? "" item = Item(name: name) } } The problem tho, is that I have an error on let name = nameTextField.text ?? "" that says i'm using an unresolved identifier 'nameTextField'. . . How do I fix this?
1 Resposta
0
Use the same name that you defined for your text field instead of nameTextField,
In my case. I named it textFieldTodoList
For eg: in viewcontroller.swift look for,
@IBOutlet weak var textFieldTodoList: UITextField!
....
Below in the function,
let name = textFieldTodoList.text ?? “”