O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

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

User Defaults

When you need to save a little bit of data in your app, the NSUserDefaults object is a very simple and easy way to do so. NSUserDefaults is a front-end to a key-value file (often referred to as Plist files because of the .plist extension) that is stored in the app’s Preferences directory. There’s only one file, but in this file you can store as many values as you want. When storing values in the file, you have to supply a key string to identify the value when retrieving it later. You can store many data types in NSUserDefaults, including all scalar types as well as NSData, NSString, NSNumber, NSDate, NSDictionary, and NSArray. Other data types can be archived and stored as an NSData 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