UserDefaults
Last updated
Last updated
The NSUserDefaults
class provides a programmatic interface for interacting with the defaults system. The defaults system allows an app to customize its behavior to match a user’s preferences. For example, you can allow users to specify their preferred units of measurement or media playback speed. Apps store these preferences by assigning values to a set of parameters in a user’s defaults database. The parameters are referred to as defaults because they’re commonly used to determine an app’s default state at startup or the way it acts by default.
At runtime, you use NSUserDefaults
objects to read the defaults that your app uses from a user’s defaults database. NSUserDefaults
caches the information to avoid having to open the user’s defaults database each time you need a default value. When you set a default value, it’s changed synchronously within your process, and asynchronously to persistent storage and other processes.
As per the Apple documentation, NSUserDefaults is used for customization as per the user's preferences. Many times, the developer uses the NSUderDefaults format to store sensitive information.