问题
Hello I am trying to make action extension to only work with a single GIF file. Here is my code (created using the snippet provided in Apple's documentation:
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.compuserve.gif"
).@count == $extensionItem.attachments.@count
).@count == 1
This extension is supposed to work inside Photos app and I have tried multiple scenarios: Single GIF file, Single Non-GIF file, Multiple Non-GIF files, Mix of GIF and Non-GIF files, and Multiple GIF files.
All the above scenarios work except for Multiple GIF files - if I select multiple items, the action reappears.
I want the action to only appear when I am using single GIF. What am I doing wrong with the predicate above?
回答1:
From debugging the code, it seems like it is a single extension item with a bunch of attachments. So to support only a single attachment you would to do the following:
Replace $extensionItem.attachments.@count with 1.
This should hide your extension if you are selecting more than 1 GIF file.
来源:https://stackoverflow.com/questions/34549427/action-extension-activation-rule-predicate-doesnt-hide-the-action-when-multiple