1

我开发了一个共享扩展并从照片和笔记应用程序中导入照片和笔记。我想将可以导入的照片数量限制为 10,但对于照片,我可以选择无限的照片。以下是来自扩展名 info.plist 的查询。任何人都可以调查它并指导我更正查询。

<key>NSExtension</key>
<dict>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationRule</key>
        <string>SUBQUERY (
            extensionItems,
            $extensionItem,
            SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
            ).@count == $extensionItem.attachments.@count).@count == 1
            OR
            SUBQUERY(extensionItems, $extensionItem, SUBQUERY($extensionItem.attachments, $attachment, SUBQUERY($attachment.registeredTypeIdentifiers, $uti, NOT $uti UTI-CONFORMS-TO "public.url" AND NOT $uti UTI-CONFORMS-TO "public.file-url" AND $uti UTI-CONFORMS-TO "public.plain-text").@count &gt;= 1).@count &gt;= 1).@count &gt;= 1
        </string>
    </dict>
4

2 回答 2

4

得到了答案。更改是针对行 @count == $extensionItem.attachments.@count).@count == 1 到
@count <= 10).@count >= 1 这表示您的计数应该是 <=10 并且 >=1

 <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>NSExtensionActivationRule</key>
            <string>SUBQUERY (
                extensionItems,
                $extensionItem,
                SUBQUERY (
                $extensionItem.attachments,
                $attachment,
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
                ).@count &lt;= 10).@count &gt;= 1
                OR
                SUBQUERY(extensionItems, $extensionItem, SUBQUERY($extensionItem.attachments, $attachment, SUBQUERY($attachment.registeredTypeIdentifiers, $uti, NOT $uti UTI-CONFORMS-TO "public.url" AND NOT $uti UTI-CONFORMS-TO "public.file-url" AND $uti UTI-CONFORMS-TO "public.plain-text").@count &gt;= 1).@count &gt;= 1).@count &gt;= 1
            </string>
        </dict>
于 2015-08-28T09:41:00.513 回答
1

IN ShareExtension 信息添加

<key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>NSExtensionActivationRule</key>
            <dict>
                <key>NSExtensionActivationSupportsImageWithMaxCount</key>
                <integer>1</integer>
            </dict>
        </dict>
于 2016-11-22T13:15:41.677 回答