Cocoa Programming for OS X: The Big Nerd Ranch Guide
by Aaron Hillegass, Adam Preble, Nate Chandler
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 ...