Silver Challenge

Right now, users of VocalTextEdit can click the Speak or Stop buttons at any time. That is not ideal: clicking Speak while VocalTextEdit is currently synthesizing will abruptly restart the vocalization, for example. Modify VocalTextEdit so that users can only click on Speak if the application is not currently synthesizing, and only click Stop when it is.

To complete this challenge, you will need a way to set the enabled property of the two buttons. You will also need a way to know when speaking ends. (You already know when it starts.) Investigate the documentation for the NSSpeechSynthesizerDelegate protocol to find out how to do these things.

Get Swift Programming: 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.