Type Function Return value none Revision Release 2022.3683 Keywords iCloud, sync, storage, document, docConflicts See also iCloud.docConflictData() iCloud.docResolve() iCloudDocEvent event.conflicts iCloud.*
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.
If there are document conflicts, the iCloudDocEvent will contain the event.conflicts table. These conflicts should be resolved.
iCloud.docConflicts( params )
Table. Table containing
Valid keys for the params
table include:
filename
— Required; name of the file to check for conflicts.
onComplete
— Required listener function to be invoked with an iCloudDocEvent.
containerId
— Optional string value indicating a specific iCloud Container to be used for document storage. Do not pass this parameter if you have only one iCloud Container associated with your app.
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 } )