Class: SC.UserDefaults
Extends
SC.Object.
The UserDefaults object provides an easy way to store user preferences in
your application on the local machine. You use this by providing built-in
defaults using the SC.userDefaults.defaults()
method. You can also
implement the UserDefaultsDelegate interface to be notified whenever a
default is required.
You should also set the userDomain
property on the defaults on page load.
This will allow the UserDefaults application to store/fetch keys from
localStorage
for the correct user.
You can also set an appDomain
property if you want. This will be
automatically prepended to key names with no slashes in them.
SC.userDefaults.getPath("global
:contactInfo.userName");
Defined in: user_defaults.js
- Since:
- SproutCore 1.0
Field Summary
- Fields borrowed from SC.Object:
- concatenatedProperties, isDestroyed, isObject, nextProperty, object, property, target, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
Instance Methods
- defaults(newDefaults)
- init()
- readDefault(keyName)
- resetDefault(keyName)
- unknownProperty(key, value)
- writeDefault(keyName, value)
Field Detail
appDomainThe default app domain for the user. Any keys that do not include a slash will be prefixed with this app domain key when getting/setting.
the default domain for the user. This will be used to store keys in local storage. If you do not set this property, the wrong values may be returned.
Instance Method Detail
Invoke this method to set the builtin defaults. This will cause all properties to change.
- Parameters:
- newDefaults
Attempts to read a user default from local storage. If not found on
localStorage
, use the the local defaults, if defined. If the key passed
does not include a slash, then add the appDomain
or use "app/".
- Parameters:
- keyName String
- Returns:
- SC.UserDefaults
- receiver