pauseSyncForUbiquitousItem(at:completionHandler:)
Asynchronously pauses sync of an item at the given URL.
Declaration
func pauseSyncForUbiquitousItem(at url: URL, completionHandler: @escaping @Sendable ((any Error)?) -> Void)func pauseSyncForUbiquitousItem(at url: URL) async throwsParameters
- url:
The URL of the item for which to pause sync.
- completionHandler:
A closure or block that the framework calls when the pause action completes. It receives a single Nserror parameter to indicate an error that prevented pausing; this value is
nilif the pause succeeded. In Swift, you can omit the completion handler and catch the thrown error instead.
Discussion
Call this when opening an item to prevent sync from altering the contents of the URL. Once paused, the file provider will not upload local changes nor download remote changes.
While paused, call uploadLocalVersionOfUbiquitousItem(at:withConflictResolutionPolicy:completionHandler:) when the document is in a stable state. This action keeps the server version as up-to-date as possible.
If the item is already paused, a second call to this method reports success. If the file provider is already applying changes to the item, the pause fails with an NSFileWriteUnknownError, with an underlying error that has domain NSPOSIXErrorDomain and code EBUSY. If the pause fails, wait for the state to stabilize before retrying. Pausing also fails with featureUnsupported if url refers to a regular (non-package) directory.
Pausing sync is independent of the calling app’s lifecycle; sync doesn’t automatically resume if the app closes or crashes and relaunches later. To resume syncing, explicitly call resumeSyncForUbiquitousItem(at:with:completionHandler:). Always be sure to resume syncing before you close the item.
See Also
Controlling file provider synchronization
NSFileManagerSupportedSyncControlsresumeSyncForUbiquitousItem(at:with:completionHandler:)NSFileManagerResumeSyncBehaviorfetchLatestRemoteVersionOfItem(at:completionHandler:)NSFileVersionuploadLocalVersionOfUbiquitousItem(at:withConflictResolutionPolicy:completionHandler:)NSFileManagerUploadLocalVersionConflictPolicy