NSExtension Share Extension limit Photos count

故事扮演 提交于 2019-12-06 14:17:40

问题


I have developed a Share Extension and import Photos and Notes from Photos and Notes App. I want to limit the count of Photos which can be import to only 10 but for Photos i am able to select unlimited photos. Below is the query from info.plist of extension. Can anyone look into it and guide me to correct query.

<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>

回答1:


Got the answer. The change is for line @count == $extensionItem.attachments.@count).@count == 1 to
@count <= 10).@count >= 1 Which says your count should be <=10 and >=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>



回答2:


IN ShareExtension Info add

<key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>NSExtensionActivationRule</key>
            <dict>
                <key>NSExtensionActivationSupportsImageWithMaxCount</key>
                <integer>1</integer>
            </dict>
        </dict>


来源:https://stackoverflow.com/questions/32265065/nsextension-share-extension-limit-photos-count

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