Contents

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

Deleteitem(withidentifier:completionhandler:)

Imports a document

Importdocument(at:toparentitemidentifier:completionhandler:)

Renames a document or folder

Renameitem(withidentifier:toname:completionhandler:)

Moves a document or folder

Reparentitem(withidentifier:toparentitemwithidentifier:newname:completionhandler:)

Sets or changes a folder’s favorite rank

Setfavoriterank(_:foritemidentifier:completionhandler:)

Uses a document

Setlastuseddate(_:foritemidentifier:completionhandler:)

Tags or untags a document or folder

Settagdata(_:foritemidentifier:completionhandler:)

Moves a document or folder to the trash

Trashitem(withidentifier:completionhandler:)

Removes a document or folder from the trash

Untrashitem(withidentifier:toparentitemidentifier:completionhandler:)

When the action method is called, ensure that your implementation:

  1. Makes any necessary local changes, including updates to the working set

  2. Schedules a background update for your server

  3. Signals that the changes have occurred

  4. 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