Skip to Content
Beginning iOS 5 Application Development
book

Beginning iOS 5 Application Development

by Wei-Meng Lee
January 2012
Beginner content levelBeginner
655 pages
16h 35m
English
Wrox
Content preview from Beginning iOS 5 Application Development

SUMMARY

This chapter explained how you can make use of the Application Preferences feature of the iPhone to save your application preferences to the Settings application. This enables you to delegate most of the mundane tasks of saving and loading an application's preferences settings to the OS. All you need to do is use the NSUserDefaults class to programmatically access the preferences settings.

EXERCISES

  1. You have learned that you can use the NSUserDefaults class to access the preferences settings values for your application. What are the methods for retrieving and saving the values?
  2. What are the two ways in which you can remove the preferences settings for an application?

Answers to the exercises can be found in Appendix D.

imageWHAT YOU LEARNED IN THIS CHAPTER

TOPIC KEY CONCEPTS
Adding application preferences to your application Add a Settings Bundle file to your project and modify the Root.plist file.
Loading the value of a preference setting
NSUserDefaults *defaults =
[NSUserDefaults standardUserDefaults];
loginName.text = [defaults
   objectForKey:@“login_name”];
Resetting preferences settings values Remove the entire application either from the Home screen or via the iPhone Simulator folder on your Mac.
Saving the value of a preference setting
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject :loginName.text forKey: @“login_name”]; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering iOS 12 Programming - Third Edition

Mastering iOS 12 Programming - Third Edition

Donny Wals
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9781118144251Purchase book