O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

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

Using NSUserDefaults

What we need to do now is store a value to specify the map type that the user last selected so that the chosen type will automatically be displayed when the user launches the application again. This value will be stored in an instance of NSUserDefaults.

Every application has an instance of NSUserDefaults that it can access by sending the class message standardUserDefaults to the NSUserDefaults class. This instance of NSUserDefaults is like an NSMutableDictionary; you can access objects in it using a key. It is also automatically read from disk when the application first accesses it and written to disk when it is modified.

The keys of an NSUserDefaults are always of type NSString. A key identifies a preference. An object ...

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