Create Names for the Defaults

You will be registering factory defaults, writing user preferences for defaults, and reading values for defaults, all based on a string that names each default. You will define a constant string for each of the default names.

At the top of PreferenceManager.swift, above the PreferenceManager, add the following constants:

i​m​p​o​r​t​ ​F​o​u​n​d​a​t​i​o​n​

p​r​i​v​a​t​e​ ​l​e​t​ ​a​c​t​i​v​e​V​o​i​c​e​K​e​y​ ​=​ ​"​a​c​t​i​v​e​V​o​i​c​e​"p​r​i​v​a​t​e​ ​l​e​t​ ​a​c​t​i​v​e​T​e​x​t​K​e​y​ ​=​ ​"​a​c​t​i​v​e​T​e​x​t​"​

c​l​a​s​s​ ​P​r​e​f​e​r​e​n​c​e​M​a​n​a​g​e​r​ ​{​

Why define constants that simply contain a fixed string? After all, you could just remember what the string was and type it in whenever ...

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.