public interface NSFileProviderItem
| Modifier and Type | Method and Description |
|---|---|
default long |
capabilities()
The capabilities of the item.
|
default NSNumber |
childItemCount() |
default NSDate |
contentModificationDate() |
default UTType |
contentType()
ContentType (UTType) for the item.
|
default NSDate |
creationDate() |
default NSNumber |
documentSize() |
default NSError |
downloadingError()
An error that occurred while downloading from your remote server.
|
default NSNumber |
favoriteRank()
The presence of a favorite rank indicates that a directory is a favorite.
|
java.lang.String |
filename()
The file or directory name, complete with its file extension.
|
default boolean |
isDownloaded()
When using NSFileProviderExtension, downloaded and downloading are used to inform the cloud badge
which will be shown on the item.
|
default boolean |
isDownloading() |
default boolean |
isMostRecentVersionDownloaded() |
default boolean |
isShared() |
default boolean |
isSharedByCurrentUser() |
default boolean |
isTrashed()
Set on a directory or a document if it should appear in the trash.
|
default boolean |
isUploaded()
Uploaded and uploading are used to inform the cloud badge which will be shown on the item.
|
default boolean |
isUploading() |
java.lang.String |
itemIdentifier()
The identifier of the item.
|
default NSDate |
lastUsedDate()
The date this item was last used.
|
default NSPersonNameComponents |
mostRecentEditorNameComponents() |
default NSPersonNameComponents |
ownerNameComponents()
ownerNameComponents should be nil when sharedByCurrentUser is equal to YES or
when the item is not shared.
|
java.lang.String |
parentItemIdentifier()
The parent identifier specifies the parent of the item in the hierarchy.
|
default NSData |
tagData()
An abstract data blob representing the tags associated with the item.
|
default java.lang.String |
typeIdentifier()
Uniform type identifier (UTI) for the item.
|
default NSError |
uploadingError()
An error that occurred while uploading to your remote server.
|
default NSDictionary<?,?> |
userInfo()
Use this dictionary to add state information to the item.
|
default NSData |
versionIdentifier()
The versionIdentifier is used to invalidate the thumbnail in the thumbnail cache.
|
default long capabilities()
Capabilities on an item only apply to the item itself. They are not inherited by the children of directories.
default NSNumber childItemCount()
default NSDate contentModificationDate()
default NSDate creationDate()
default NSNumber documentSize()
default NSError downloadingError()
default NSNumber favoriteRank()
When favoriting folders on other platforms, set the rank to the time since the unix epoch in milliseconds. Special value @(NSFileProviderFavoriteRankUnranked) may be used if no rank is available: the system will then figure out the best rank and set it. Please persist and sync the new value.
This property must not be shared between users, even if the item is.
java.lang.String filename()
The filename property must not be an empty string, including when the item identifier is NSFileProviderRootContainerItemIdentifier. The filename for NSFileProviderRootContainerItemIdentifier may be displayed in the user interface. Therefore it should be a user-friendly string.
default boolean isDownloaded()
When using NSFileProviderReplicatedExtension, downloaded and downloading are ignored, as they can be inferred from the result of calls to fetchContentsForItemWithIdentifier.
default boolean isDownloading()
default boolean isMostRecentVersionDownloaded()
default boolean isShared()
default boolean isSharedByCurrentUser()
default boolean isTrashed()
This flag should only be set on the top-level item: trashing a directory sets this flag on the directory itself, but not on its children.
Trashed items should remain in the working set; however, children of trashed directories should be removed from the working set.
Additionally, when an item is trashed, the `parentItemIdentifier` refers to the location the item was before being trashed. As such, when the user decides to restore the item from trash, `parentItemIdentifier` will be used for the default restore location.
default boolean isUploaded()
When using NSFileProviderReplicatedExtension, uploaded is used to inform whether the item may be evicted from the local disk. If you choose to finish uploading items after calling the completion handler of creteItem/modifyItem, you must set the uploaded flag to false, in order for the item to be excluded from eviction.
default boolean isUploading()
java.lang.String itemIdentifier()
The itemIdentifier should not contain sensitive information, as it may be recorded in system logs and diagnostic files.
default NSDate lastUsedDate()
This is the system's cue that the document is recent and should appear in the recent list of the UIDocumentBrowserViewController.
This property must not be shared between users, even if the item is.
default NSPersonNameComponents mostRecentEditorNameComponents()
default NSPersonNameComponents ownerNameComponents()
java.lang.String parentItemIdentifier()
Set to NSFileProviderRootContainerItemIdentifier for an item at the root of the user's storage. Set to the itemIdentifier of the item's parent otherwise.
When enumerating the root container or a generic container, the parentItemIdentifier of the enumerated items is expected to match the enumerated item's identifier. When enumerating the working set, the parentItemIdentifier is expected to match the actual parent of the item in the hierarchy (ie. it is not NSFileProviderWorkingSetContainerItemIdentifier).
The parents of trashed items and of the root item are ignored.
default NSData tagData()
This property must not be shared between users, even if the item is.
Starting in macOS 12 and iOS 15, the system suppports the value of the `com.apple.metadata:_kMDItemUserTags` xattr as a valid `tagData` blob input.
default java.lang.String typeIdentifier()
This property is deprecated in favor of the "contentType" property.
On macOS, typeIdentifier is not available. Items must implement contentType on macOS.
On iOS, items must implement either contentType or typeIdentifier. Note that contentType is not available on iOS 13 and earlier, so typeIdentifier is required in order to target iOS 13 and earlier.
default NSError uploadingError()
\note Typical uploading errors include: - NSFileProviderErrorInsufficientQuota - NSFileProviderErrorServerUnreachable
\seealso NSFileProviderErrorInsufficientQuota \seealso NSFileProviderErrorServerUnreachable
default NSDictionary<?,?> userInfo()
Additionally, any entry of this dictionary with a key ending in `.inherited` will be accessible to predicates for descendants of this item via the context key `inheritedUserInfo`.
Items can redefine inherited values for their descendants by specifying the same key used in an ancestor's `userInfo`. Thus, `inheritedUserInfo` for a given item is a dictionary of `*.inherited` keys from all if its ancestors, with each value taken from the nearest ancestor that has the entry defined.
In this example directory structure: root |_ parent |_ child |_ grandchild
with the following userInfo values set: parent.userInfo = { "a.inherited": YES, "b.inherited": YES } child.userInfo = { "a.inherited": NO, "c.inherited": NO } grandchild.userInfo = { }
the following inheritedUserInfo values will be provided: parent.inheritedUserInfo = { } child.inheritedUserInfo = { "a.inherited": YES, "b.inherited": YES } grandchild.inheritedUserInfo = { "a.inherited": NO, "b.inherited": YES, "c.inherited": NO }
The context key `resolvedUserInfo` is also available. For each item, the resolvedUserInfo is it's inheritedUserInfo, combined with the keys suffixed with .inherited from it's userInfo. Continuing the previous example: parent.resolvedUserInfo = { "a.inherited": YES, "b.inherited": YES } child.resolvedUserInfo = { "a.inherited": NO, "b.inherited": YES, "c.inherited": NO } grandchild.resolvedUserInfo = { "a.inherited": NO, "b.inherited": YES, "c.inherited": NO }
All values for this dictionary must be of type String, Number, Bool or Date.
[1] UserInteraction can be defined when a user level action occurs with a file.
- `NSFileProviderUserInteractions` *array* - `ActivationRule ` *string*, the predicate. [@parameters] predicates - `destinationItem`: the destination item for an action. Present for Move/MoveIn/Copy/CopyIn/Create - `action` : the action that is being performed 'Move' : moving item(s) within the same provider 'MoveOut' : moving item(s) out of the provider 'MoveIn' : importing item(s) into a folder/root of the provider 'Copy' : copying item(s) within the same provider 'CopyOut' : copying item(s) out of the provider 'CopyIn' : copying item(s) into a folder/root of the provider 'Trash' : trashing item(s) 'Create' : creating an item (available in macOS 12.0 and later) The Create action will be evaluated when the user creates a new file or folder in a system Open/Save panel. The sourceItem is the file/folder being created. The only field that is populated for this item is the filename. The type of file/folder, size, etc, are unknown at Create evaluation time. The destinationItem is the directory which the file/folder is being created within. 'Delete' : deleting item(s) If the provider wishes to take full responsibility for showing warnings on Delete, the provider can set NSExtensionFileProviderAllowsSystemDeleteAlerts=0 in the provider's Info.plist. This will ensure that the system does not display it's warnings when the user is deleting a file. 'ExcludeFromSync' : deleting items(s) because the user chose to exclude those from sync (available in macOS 12.0 and later) 'Rename' : renaming item(s) (available in macOS 11.3 and later) The destinationItem has only the `filename` field populated (available in macOS 12.0.1 and later). - `sourceItem` : current item that the predicate is evaluating. Present for Move/MoveOut/Copy/CopyOut/Create/Trash/Delete/ExcludeFromSync/Rename - `sourceItemsCount` : - In userInteraction, represents the count of sourceItems of an action operation - In subUserInteraction: represents the count of items that matched the previous predicate - `domainUserInfo`: The latest dictionary returned from -[NSFileProviderDomainState userInfo] - `Alert` *dictionary* - `LocalizedTitle` *string*, title of the alert - `LocalizedSubTitle` *string*, sub title of the alert - @parameters for LocalizedTitle/LocalizedSubTitle - `matchingItemsCount`: count of source items that matched the predicate (only present if matchingItemsCount > 0) - `matchingItemsCountMinusOne`: matchingItemsCount minus one (only present if matchingItemsCount > 1) - `matchingItemsCountMinusTwo`: matchingItemsCount minus two (only present if matchingItemsCount > 2) - `firstMatchingItem`: first sourceItem that matched the predicate (only present if matchingItemsCount > 1) - `secondMatchingItem`: second sourceItem that matched the predicate (only present if matchingItemsCount > 2) - `LocalizedRecoveryOptions` - `Continue` *string*, the string for the continue button - default value if not specified - `Cancel` *string*, the string for the cancel button - default value if not specified - `RecoveryOptions` (optional) - `Continue` *bool*, the boolean for whether to have a continue button - default value is YES if not specified - `Destructive` *bool*, the boolean for whether continuing is a destructive action - default value is NO if not specified - `HelpURL` *string*: If present, a help button will be displayed on the Alert that is shown. If the user clicks the help button, this help URL will be opened. This URL is not restricted to Web URLs. For instance, the extension could configure the HelpURL to launch it's application with a custom URL scheme. (available in macOS 12.0 and later) - `SubInteractions `: *dictionary* (same as `NSFileProviderUserInteractions`) - `SupressionIdentifier` *string*: If present, when this predicate matches, the alert will display an option to suppress future alerts from UserInteractions with the same SuppressionIdentifier (including the current UserInteraction). This also requires implementing the `NSFileProviderUserInteractionSuppressing` protocol on the principal class of the FileProvider extension (available in macOS 12.0 and later).
For each interaction, either Alert or SubInteractions must be specified. SubInteractions will be evaluated if the main ActivationRule evaluates to YES for at least once. This allows you to match a general pattern via the top-level activation rule and then select a specialized error message from a list of subpatterns.
At most one UserInteraction alert will be shown for each FileProvider domain involved in the user's Action. For instance, if provider A defines a UserInteraction for MoveOut actions, and provider B defines a UserInteraction for MoveIn operations. When the user moves a file from A to B, and the predicate for both UserInteraction matches, then both of the UserInteraction alerts will be shown to the user. However, as soon as the user denies any of the alerts, the remainder will not be shown, and the action will be denied.
If the provider wishes to take full responsibility for showing a custom contextual menu item for Download, the provider can set NSExtensionFileProviderAllowsContextualMenuDownloadEntry=0 in the provider's Info.plist. This will ensure that the system does not display the "Download Now" button in the contextual menu.
Here is a sample extension Info.plist:
```
default NSData versionIdentifier()
Version identifiers are limited to 1000 bytes.
This property is deprecated in favor of the "itemVersion" property.
default UTType contentType()
On macOS, items must implement contentType.
On iOS, items must implement either contentType or typeIdentifier. Note that contentType is not available on iOS 13 and earlier, so typeIdentifier is required in order to target iOS 13 and earlier.
When using NSFileProviderReplicatedExtension, providers must be prepared to handle the following contentType in the appropriate manner when they are passed in itemTemplates contentType to createItem/modifyItem calls: * UTType.symbolicLink * UTType.folder * UTType.package * UTType.aliasFile
Changing the contentType for a given item that would result in a transition to/from a folder or to/from a symlink is not supported.