OGeek|极客世界-中国程序员成长平台

标题: ios - iOS 共享扩展中的子查询排除文件类型 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:14
标题: ios - iOS 共享扩展中的子查询排除文件类型

我的共享扩展有以下 NSExtensionActivationRule,它允许我的应用程序与图像和 pdf 文件交互:

SUBQUERY (
    extensionItems, $extensionItem,
    SUBQUERY (
        $extensionItem.attachments, $attachment,
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
    ).@count == 1
).@count > 0

但是,由于我使用不同的方法访问我自己的文件,我需要不为我的应用程序文档类型为 com.myApp.extension 的文件显示我的应用程序。
有没有改进的方法:

ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url

这样它排除特定类型的文件。

谢谢
礼萨



Best Answer-推荐答案


<key>NSExtensionAttributes</key>
<dict>
    <key>NSExtensionActivationRule</key>
    <string>
    SUBQUERY (
        extensionItems,
        $extensionItem,
            SUBQUERY (
                $extensionItem.attachments,
                $attachment,
                (ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" OR
                ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png")
                AND NOT (ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "your.unique.uti.here")
            ).@count == $extensionItem.attachments.@count
    ).@count == 1
    </string>
</dict>

关于ios - iOS 共享扩展中的子查询排除文件类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40016837/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4