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​ ...

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.