Skip to content
Titanium SDK
unreleased
Versionmainunreleased

Titanium.App.iOS.UserDefaults

moduleiPhoneiPadmacOSsince 4.0.0

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

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

suiteName

String

Sets 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
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

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
ParametersTypeDescription
propertyString

Name of property.

default?Boolean

Default value to return if property does not exist.

Returns Boolean

Inherited from Titanium.App.Properties

Returns the value of a property as a double (double-precision, floating point) data type.

Parameters
ParametersTypeDescription
propertyString

Name of property.

default?Number

Default value to return if property does not exist.

Returns Number

Inherited from Titanium.App.Properties

Returns the value of a property as an integer data type.

Parameters
ParametersTypeDescription
propertyString

Name of property.

default?Number

Default value to return if property does not exist.

Returns Number

Inherited from Titanium.App.Properties

Returns the value of a property as an array data type.

Parameters
ParametersTypeDescription
propertyString

Name of property.

default?Array<Object>

Default value to return if property does not exist.

Returns Array<Object>

Inherited from Titanium.App.Properties

Returns the value of a property as an object.

Parameters
ParametersTypeDescription
propertyString

Name of property.

default?Object

Default value to return if property does not exist.

Returns Object

Inherited from Titanium.App.Properties

Returns the value of a property as a string data type.

Parameters
ParametersTypeDescription
propertyString

Name of property.

default?String

Default value to return if property does not exist.

Returns String

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

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
ParametersTypeDescription
propertyString

Name of property.

valueBoolean

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
ParametersTypeDescription
propertyString

Name of property.

valueNumber

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
ParametersTypeDescription
propertyString

Name of property.

valueNumber

Property value, within the range -2,147,483,648 to 2,147,483,647.

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
ParametersTypeDescription
propertyString

Name of property.

valueArray<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
ParametersTypeDescription
propertyString

Name of property.

valueObject

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
ParametersTypeDescription
propertyString

Name of property.

valueString

Property value.

Events 1