O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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​"​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required