![]() While more complex objects can be stored as generic data, this practice is discouraged since it reduces flexibility. Developers are encouraged to keep the values associated with those keys to one of several basic types: strings, numbers, Boolean values or dates. The key is a unique string that identifies a specific preference within a specific domain. User preferences are stored as key-value pairs. This is where any application-specific preferences are stored. Every iOS application has its own application domain in the user’s defaults database. The application and registration domain however, are where an iOS developer will go to set any application-specific default values and will be the focus of the rest of this post. In most iOS apps, a developer will seldom need to delve into the default settings in any of these domains. The global domain contains properties that the OS sets and uses throughout all application and the languages domain records language-specific preference values. The argument domain contains default properties that have been set at the command-line. For the most part in iOS, developers work with the application and registration domains. There are five different domains in the user defaults system: the argument domain, the application domain, the global domain, the language domain and the registration domain. The user defaults system keeps the values stored in its database categorized according to domains. ![]() When a developer wants to be able to save preference settings or certain aspects of the state of the application, he or she will be using the user defaults system to interact with that user’s defaults database. The user defaults system maintains a defaults database that the OS uses to keep track of the various preferences (or defaults) that the user has set at a global or application-specific level. Applications in OS X and iOS use the user defaults system to store preferences. What is the User Defaults System?īefore I can address NSUserDefaults and how to make use of it, I want to explain the user defaults system in OS X and iOS. In this blog post, I hope to explain the user defaults system and what NSUserDefaults is, how it works and some pretty good practices to follow when implementing these defaults. In all of these and many other cases, storing this information in the user defaults system and accessing it with NSUserDefaults is a good solution. Perhaps and app can display information in different, user-selectable units, perhaps the user should be able to enable or disable certain features or perhaps the developer wants to keep track of certain aspects of the state of the app so that it can be restored at a later time. “How do I store user preferences in my iOS app?” is a pretty common question most developers face at some point in their app development career.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |