January 2012
Beginner
655 pages
16h 35m
English
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
Answers to the exercises can be found in Appendix D.
WHAT 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”]; ... |