resumeSyncForUbiquitousItem(at:with:completionHandler:)
Asynchronously resumes the sync on a paused item using the given resume behavior.
Declaration
func resumeSyncForUbiquitousItem(at url: URL, with behavior: NSFileManagerResumeSyncBehavior, completionHandler: @escaping @Sendable ((any Error)?) -> Void)func resumeSyncForUbiquitousItem(at url: URL, with behavior: NSFileManagerResumeSyncBehavior) async throwsParameters
- url:
The URL of the item for which to resume sync.
- behavior:
A Nsfilemanagerresumesyncbehavior value that tells the file manager how to handle conflicts between local and remote versions of files.
- completionHandler:
A closure or block that the framework calls when the resume action completes. It receives a single Nserror parameter to indicate an error that prevented the resume action; the value is
nilif the resume succeeded. In Swift, you can omit the completion handler and catch the thrown error instead.
Discussion
Always call this method when your app closes an item to allow the file provider to sync local changes back to the server.
In most situations, the NSFileManagerResumeSyncBehavior.preserveLocalChanges behavior is the best choice to avoid any risk of data loss.
The resume call fails with featureUnsupported if url isn’t currently paused. If the device isn’t connected to the network, the call may fail with NSFileWriteUnknownError, with the underlying error of serverUnreachable.
See Also
Controlling file provider synchronization
NSFileManagerSupportedSyncControlspauseSyncForUbiquitousItem(at:completionHandler:)NSFileManagerResumeSyncBehaviorfetchLatestRemoteVersionOfItem(at:completionHandler:)NSFileVersionuploadLocalVersionOfUbiquitousItem(at:withConflictResolutionPolicy:completionHandler:)NSFileManagerUploadLocalVersionConflictPolicy