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

14 User Defaults

Many applications allow you, as the user, to configure their behavior or appearance. Cocoa provides a simple means of storing such preferences in the user’s defaults database.

NSUserDefaults

The NSUserDefaults class is your interface to the user’s defaults database. With it you can register factory defaults, set the user’s defaults, and read the defaults back out as needed. You can think of it as a very fancy dictionary.

Your application can register a set of defaults “from the factory.” These are the defaults that your application uses when users have not made their own configuration selections. These factory defaults are registered programmatically every time your application is launched.

When ...

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