iCloud.docConflicts()

Type Function
Return value none
Revision 2017.3060
Keywords iCloud, sync, storage, document, docConflicts
See also iCloud.docConflictData()
iCloud.docResolve()
iCloudDocEvent
event.conflicts
iCloud.*

Overview

Sometimes the same file will be simultaneously modified from several locations and iCloud will not be able to synchronize the changes. In this case a conflict will occur. Call this function to check for conflicts and invoke the onComplete listener function with an iCloudDocEvent upon completion.

Important

If there are document conflicts, the iCloudDocEvent will contain the event.conflicts table. These conflicts should be resolved.

Syntax

iCloud.docConflicts( params )
params (required)

Table. Table containing method-specific parameters — see the next section for details.

Parameter Reference

Valid keys for the params table include:

Example

local function printConflictData( event )

    print( "Conflict contents: " .. event.contents )
end

local function docListener( event )

    if event.conflicts then
        for i = 1,#event.conflicts do
            print( "Conflict origin: " .. event.conflicts[i].origin )
            print( "Conflict time: " .. event.conflicts[i].time )

            iCloud.docConflictData(
                {
                    conflict = event.conflicts[i].dataHandle,
                    onComplete = printConflictData
                }
            )
        end
    end
end

iCloud.docConflicts(
    {
        filename = "test.txt",
        onComplete = docListener
    }
)