April 2015
Intermediate to advanced
556 pages
17h 47m
English
Open the Dice project from Chapter 18. Although it would be cheating, users would like to be able to set the number on the face of the die by typing a number from one to six.
Your first task in adding keyboard support is to accept first responder. Add the following property and methods to DieView:
// MARK: - First Responder
override var acceptsFirstResponder: Bool { return true }
override func becomeFirstResponder() -> Bool {
return true
}
override func resignFirstResponder() -> Bool {
return true
}
Remember that without accepting first responder your view cannot receive keyboard events.
You could implement keyDown(_:) and interpret ...