iCloud.set()

Type Function
Return value none
Revision Release 2024.3703
Keywords iCloud, sync, storage, Key-Value Storage, KVS, set
See also iCloud.get()
iCloud.synchronize()
iCloud.*

Overview

Associates a value with a key. This key-value pair will eventually be synchronized across the user's iCloud-enabled devices.

Syntax

iCloud.set( key, value )
key (required)

String. The key name to associate with a value. This name can be used with iCloud.get() to retrieve the value.

value (required)

String, Number, or Table. The value to be associated with the key. Tables must contain named key-value pairs and have similar types for their values.

Gotchas

local arr = { true, false, 0, 10 }  -- This is analogous to { 1=true, 2=false, 3=0, 4=10 }
iCloud.set( "myArray", arr )        -- This will produce an error and the value will not be stored

Examples

iCloud.set( "touches", 52 )
iCloud.set( "rose", { kind="flower", color="red", amount=12 } )
iCloud.set( "engine", "Corona" )

local json = require( "json" )
iCloud.set( "data", json.encode( someTable ) )