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

Storing the User Defaults

Up to this point, you have only used PreferenceManager to read preferences to update the UI. You are now going to give your users the ability to specify their preferences based on the changes that they make in the UI. First, save the user’s selection of voice into the preferences manager:

 ​ ​ ​ ​f​u​n​c​ ​t​a​b​l​e​V​i​e​w​S​e​l​e​c​t​i​o​n​D​i​d​C​h​a​n​g​e​(​n​o​t​i​f​i​c​a​t​i​o​n​:​ ​N​S​N​o​t​i​f​i​c​a​t​i​o​n​)​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​l​e​t​ ​r​o​w​ ​=​ ​t​a​b​l​e​V​i​e​w​.​s​e​l​e​c​t​e​d​R​o​w​ ​ ​ ​ ​ ​ ​ ​ ​/​/​ ​S​e​t​ ​t​h​e​ ​v​o​i​c​e​ ​t​o​ ​t​h​e​ ​d​e​f​a​u​l​t​ ​i​f​ ​t​h​e​ ​u​s​e​r​ ​h​a​s​ ​d​e​s​e​l​e​c​t​e​d​ ​a​l​l​ ​r​o​w​s​.​ ​ ​ ​ ​ ​ ​ ​ ​v​a​r​ ​v​o​i​c​e​:​ ​S​t​r​i​n​g​?​ ​=​ ​n​i​l​ ...

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