Adding Keyboard Input to DieView

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.

Accept first responder

Your first task in adding keyboard support is to accept first responder. Add the following property and methods to DieView:

/​/​ ​M​A​R​K​:​ ​-​ ​F​i​r​s​t​ ​R​e​s​p​o​n​d​e​ro​v​e​r​r​i​d​e​ ​v​a​r​ ​a​c​c​e​p​t​s​F​i​r​s​t​R​e​s​p​o​n​d​e​r​:​ ​B​o​o​l​ ​{​ ​r​e​t​u​r​n​ ​t​r​u​e​ ​ ​}o​v​e​r​r​i​d​e​ ​f​u​n​c​ ​b​e​c​o​m​e​F​i​r​s​t​R​e​s​p​o​n​d​e​r​(​)​ ​-​>​ ​B​o​o​l​ ​{​
 ​ ​ ​ ​r​e​t​u​r​n​ ​t​r​u​e}o​v​e​r​r​i​d​e​ ​f​u​n​c​ ​r​e​s​i​g​n​F​i​r​s​t​R​e​s​p​o​n​d​e​r​(​)​ ​-​>​ ​B​o​o​l​ ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.