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

Reading the Preferences

Next, you will add computed properties to your PreferenceManager class for the two preferences: activeVoice and activeText. The getter will be used to get the value for each preference. These properties will abstract away the details of how the preferences are stored. Implement these computed properties in PreferenceManager.swift:

 ​ ​ ​ ​.​.​.​

 ​ ​ ​ ​v​a​r​ ​a​c​t​i​v​e​V​o​i​c​e​:​ ​S​t​r​i​n​g​?​ ​{​
 ​ ​ ​ ​ ​ ​ ​ ​g​e​t​ ​{​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​r​e​t​u​r​n​ ​u​s​e​r​D​e​f​a​u​l​t​s​.​o​b​j​e​c​t​F​o​r​K​e​y​(​a​c​t​i​v​e​V​o​i​c​e​K​e​y​)​ ​a​s​?​ ​S​t​r​i​n​g​
 ​ ​ ​ ​ ​ ​ ​ ​}​
 ​ ​ ​ ​}​

 ​ ​ ​ ​v​a​r​ ​a​c​t​i​v​e​T​e​x​t​:​ ​S​t​r​i​n​g​?​ ​{​
 ​ ​ ​ ​ ​ ​ ​ ​g​e​t​ ​{​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​r​e​t​u​r​n​ ...

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