Providing support for user-driven actions
Override methods to handle user-initiated actions.
Overview
When the user performs an action in the document browser (for example, moving, renaming, or deleting an item) the system calls the corresponding method on your NSFileProviderExtension subclass.
The following table shows the action method for each action type:
User action | Action method |
|---|---|
Creates a new folder | Createdirectory(withname:inparentitemidentifier:completionhandler:) |
Deletes a document or folder | |
Imports a document | Importdocument(at:toparentitemidentifier:completionhandler:) |
Renames a document or folder | |
Moves a document or folder | Reparentitem(withidentifier:toparentitemwithidentifier:newname:completionhandler:) |
Sets or changes a folder’s favorite rank | |
Uses a document | |
Tags or untags a document or folder | |
Moves a document or folder to the trash | |
Removes a document or folder from the trash | Untrashitem(withidentifier:toparentitemidentifier:completionhandler:) |
When the action method is called, ensure that your implementation:
Makes any necessary local changes, including updates to the working set
Schedules a background update for your server
Signals that the changes have occurred
Calls the completion handler with the results
All the action methods are expected to work offline, and should return immediately. Call the completion handler before performing any network activity or other long-running tasks. Defer these tasks to the background.
Topics
Signaling Changes
Handling Errors
See Also
Handling actions
createDirectory(withName:inParentItemIdentifier:completionHandler:)deleteItem(withIdentifier:completionHandler:)importDocument(at:toParentItemIdentifier:completionHandler:)renameItem(withIdentifier:toName:completionHandler:)reparentItem(withIdentifier:toParentItemWithIdentifier:newName:completionHandler:)setFavoriteRank(_:forItemIdentifier:completionHandler:)setLastUsedDate(_:forItemIdentifier:completionHandler:)setTagData(_:forItemIdentifier:completionHandler:)trashItem(withIdentifier:completionHandler:)untrashItem(withIdentifier:toParentItemIdentifier:completionHandler:)