All is going well in this chapter until I get to the “Dismissing the keyboard” section. Specifically, I am confused at the sentence, “Control-drag from the Conversion View Controller to the text field on the canvas and connect it to the textField outlet.”
I can initiate the Control-drag from the Conversion View Controller, but I have no idea what to connect it to. Where exactly is the “text field on the canvas and connect it to the textField outlet”? The targets that I can Control-drag to include “value”, “degrees Fahrenheit”, etc., but I don’t think this is what is intended.
I don’t have the book, but I think you probably missed something.
In your ConversionViewController.swift, do you have an outlet declared to connect to the text field object sitting on the canvas?
For example:
class JimmyGiggleViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var miniHootTextField : UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func textFieldShouldReturn (_ textField: UITextField) -> Bool {
print (#function)
textField.resignFirstResponder()
return true
}
func textFieldDidEndEditing (_ textField: UITextField) {
assert (textField == miniHootTextField)
print (#function)
}
}
Note the following line above:
@IBOutlet var miniHootTextField : UITextField!
If you have the outlet declared, then you should be able to control-drag from the view controller object on the canvas to the text field object and see a HUD view pop up displaying the name of the outlet variable declared in the view controller.