Contents

temporaryDirectoryURL()

Returns the URL of a directory that the File Provider extension can use to temporarily store files before passing them to the system.

Declaration

func temporaryDirectoryURL() throws -> URL

Discussion

The system guarantees that the temporary URL refers to a directory on the same volume as the user-visible URL so that the system can automatically clone or move files between the temporary URL and the user-visible URL. For example, the File Provider extension can use the temporary directory to store content passed to the createItem(basedOn:fields:contents:options:request:completionHandler:) or modifyItem(_:baseVersion:changedFields:contents:options:request:completionHandler:) methods.

When you implement your File Provider extension’s fetchContents(for:version:request:completionHandler:) method, the URL you pass to the completion handler must be on the same volume as the temporary directory, so the system can clone it to provide the content for the dataless item.

This method fails if the system can’t find a suitable directory, for example, if the domain doesn’t exist. However, it can’t fail if the file provider has an active instance for the specified domain.

See Also

Working with domains