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

Adding User Defaults to SpeakLine

Over the rest of this chapter, you are going to add user defaults to your SpeakLine app. These changes will allow the user’s configuration of the text to be spoken and the voice that it will be spoken in to be persisted across runs of the app.

Rather than using NSUserDefaults directly to configure SpeakLine’s user interface and store the user’s defaults from within AppDelegate, you will write a PreferenceManager wrapper class. This class will make use of NSUserDefaults to persist preferences. AppDelegate, in turn, will use this wrapper class to access and change preferences.

Create a new Swift file, PreferenceManager.swift, in the SpeakLine group in the project navigator. In PreferenceManager.swift ...

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