You are reading 13.0.1. See this page in 13.4.1.
Titanium.App.iOS.UserDefaults
Extends Titanium.App.PropertiesTitanium.ModuleTitanium.Proxy
The UserDefaults module is used for storing application-related data in property/value pairs that persist beyond application sessions and device power cycles. UserDefaults allows the suiteName of the UserDefaults to be specified at creation time.
Important: Using this API requires the NSPrivacyAccessedAPICategoryUserDefaults property set in the
privacy manifest that was introduced in iOS 17. You can learn more about it here.
Unlike Titanium.App.Properties, Titanium.App.iOS.UserDefaults does not pull properties defined in the tiapp.xml file.
To create a UserDefaults object, use the Titanium.App.iOS.createUserDefaults method.
Examples
Create a UserDefaults object
Creating a UserDefaults object
var props = Ti.App.iOS.createUserDefaults({
suiteName: 'group.mySuite'
});
Properties 3
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
suiteName
StringSets the name of the suite to be used to access UserDefaults.
Methods 20
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Inherited from Titanium.App.Properties
Returns the value of a property as a boolean data type.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| default? | Boolean | Default value to return if property does not exist. |
Inherited from Titanium.App.Properties
Returns the value of a property as a double (double-precision, floating point) data type.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| default? | Number | Default value to return if property does not exist. |
Inherited from Titanium.App.Properties
Returns the value of a property as an integer data type.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| default? | Number | Default value to return if property does not exist. |
Inherited from Titanium.App.Properties
Returns the value of a property as an array data type.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| default? | Array<Object> | Default value to return if property does not exist. |
Inherited from Titanium.App.Properties
Returns the value of a property as an object.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| default? | Object | Default value to return if property does not exist. |
Inherited from Titanium.App.Properties
Returns the value of a property as a string data type.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| default? | String | Default value to return if property does not exist. |
Inherited from Titanium.App.Properties
Indicates whether a property exists.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
Inherited from Titanium.App.Properties
Returns an array of property names.
removeAllProperties
since 6.0.0Inherited from Titanium.App.Properties
Removes all properties that have been set by the user on runtime, or does nothing otherwise.
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Inherited from Titanium.App.Properties
Removes a property if it exists, or does nothing otherwise.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
Inherited from Titanium.App.Properties
Sets the value of a property as a boolean data type. The property will be created if it does not exist.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| value | Boolean | Property value. |
Inherited from Titanium.App.Properties
Sets the value of a property as a double (double-precision, floating point) data type. The property will be created if it does not exist.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| value | Number | Property value. |
Inherited from Titanium.App.Properties
Sets the value of a property as an integer data type. The property will be created if it does not exist.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| value | Number | Property value, within the range |
Inherited from Titanium.App.Properties
Sets the value of a property as an array data type. The property will be created if it does not exist.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| value | Array<Object> | Property value. |
Inherited from Titanium.App.Properties
Sets the value of a property as an object data type. The property will be created if it does not exist.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| value | Object | Property value. |
Inherited from Titanium.App.Properties
Sets the value of a property as a string data type. The property will be created if it does not exist.
| Parameters | Type | Description |
|---|---|---|
| property | String | Name of property. |
| value | String | Property value. |
Events 1
change
since 3.0.0Inherited from Titanium.App.Properties
Fired when a property is changed.