Updating Buttons

In this section, you are going to ensure that the Speak and Stop buttons are enabled or disabled at the appropriate times. The first step is to create a new property in MainWindowController that will keep track of whether the speech synthesizer is currently speaking.

In MainWindowController.swift, add the following code.

c​l​a​s​s​ ​M​a​i​n​W​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​:​ ​N​S​W​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​ ​{​

 ​ ​ ​ ​.​.​.​

 ​ ​ ​ ​l​e​t​ ​s​p​e​e​c​h​S​y​n​t​h​ ​=​ ​N​S​S​p​e​e​c​h​S​y​n​t​h​e​s​i​z​e​r​(​)​

 ​ ​ ​ ​v​a​r​ ​i​s​S​t​a​r​t​e​d​:​ ​B​o​o​l​ ​=​ ​f​a​l​s​e​ ​ ​ ​ ​o​v​e​r​r​i​d​e​ ​v​a​r​ ​w​i​n​d​o​w​N​i​b​N​a​m​e​:​ ​S​t​r​i​n​g​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​r​e​t​u​r​n​ ​"​M​a​i​n​W​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​"​ ...

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.