Contents

reimportItems(below:completionHandler:)

Tells the system to reimport the item and its content recursively.

Declaration

func reimportItems(below itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping  @Sendable ((any Error)?) -> Void)
func reimportItems(below itemIdentifier: NSFileProviderItemIdentifier) async throws

Parameters

  • itemIdentifier:

    The identifier of the item to reimport. The system reimports the item and all of its children.

  • completionHandler:

    A block called by the system immediately after receiving the request. The completion handler takes the following parameters:

    error

    If an error occurs, this object contains information about the error; otherwise, it’s nil.

Discussion

This method tells the system that the specified item identifiers are no longer valid. Your file provider extension should call this method if it has lost track of its synchronization state and can’t guarantee the stability of the item identifiers anymore.

The system calls createItem(basedOn:fields:contents:options:request:completionHandler:) and passes the mayAlreadyExist option for each affected identifier in its working set. Your File Provider extension can then specify a new identifier for each item.

The system then calls importDidFinish(completionHandler:) when the import is complete. If successful, the system always reimports the specified subtree, but it may reimport other items as well. If the item specified by the itemIdentifier parameter has no on-disk representation, the method fails with an NSFileProviderError.Code.noSuchItem error.

If your file provider loses synchronization but is still able to guarantee the stability of the identifiers, you don’t need to reimport the items. Instead, if the system queries the working set with an anchor that predates the synchronization loss, your File Provider extension can fail with an NSFileProviderError.Code.syncAnchorExpired error.

If your file provider loses synchronization, but you aren’t interested in preserving the local data, you can resolve the issue by removing and then adding the domain back.

See Also

Working with items