Action Extension activation rule predicate doesn't hide the action when multiple of the same type is selected

限于喜欢 提交于 2019-12-11 14:12:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!