setTagData(_:forItemIdentifier:completionHandler:)
Tags an item.
Declaration
func setTagData(_ tagData: Data?, forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping @Sendable (NSFileProviderItem?, (any Error)?) -> Void)func setTagData(_ tagData: Data?, forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier) async throws -> NSFileProviderItemParameters
- tagData:
The tag selected by the user, or
nilif the item was untagged. - itemIdentifier:
The item’s persistent identifier.
- completionHandler:
A block that takes the following parameters:
taggedItemA file provider item that represents the changed item, or
nilif an error occurred.errorAn error object. If an error occurs, pass in an object that describes the error; otherwise, set it to
nil.
Discussion
This method is called when the user tags a document or directory. Override this method to make any necessary local changes. Your implementation should return immediately. Call the completion handler before performing any network activity or other long-running tasks. Defer these tasks to the background.
The taggedItem instance that you pass to the completion handler should match the item’s old file provider item, with only one change: set the item’s tagData property with the value of the tagData parameter.
Always include Items with a non-nil tagData property in your File Provider extension’s working set.
See Also
Handling actions
Providing support for user-driven actionscreateDirectory(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:)trashItem(withIdentifier:completionHandler:)untrashItem(withIdentifier:toParentItemIdentifier:completionHandler:)