我已经为iOS应用程序实现了共享扩展。 该扩展程序可以成功处理图像和视频。
现在我正在寻找一种方法,使扩展能够用于更多文件类型,例如PDF&#s;,电子表格(Excel,页面等),文档(MS Word,其他类似类型),演示文稿( Powerpoint,Pages等),简单的文本文件(Txt,xml,.c,.h,任何其他文件)和网页URL。
问题在于我希望能够使用以下规则激活扩展程序:
1。可以一起选择图像和视频,共25个 项目,最多25个图像和/或最多5个视频。所以我们可以 只有1-25张图片或者只有1-5张视频或者20张图片和5个视频或任何组合,只要总项目保持小于或等于25且视频保持小于或等于5
2。如果是Image / s或Video / s,则无法选择其他类型 地选择。
第3。 PDF最多为1,未选择其他类型。
4。电子表格最多为5,未选择其他类型。
我一直试图通过为NSExtensionActivationRule使用自定义SUBQUERY来实现这一目标,但一直未能弄明白。
我已经经历了很多堆栈溢出帖子,还有一些帖子没有堆栈溢出,也没有通过Apple文档,除了简单的例子之外没有任何东西,但我还没有能够成功编写适合的SUBQUERY我的要求。
例如,我尝试编写以下SUBQUERY,它应该仅在选择图像时激活扩展,并且特别忽略PDF,演示文稿,音频,电影和文本文件。但扩展会被激活为文本和PDF,也可能是其他被忽略的项目,虽然我没有专门检查每一个。
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
(
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.fax"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg-2000"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.tiff"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.camera-raw-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pict"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.macpaint-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.xbitmap-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.quicktime-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.icns"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.photoshop-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.illustrator.ai-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.bmp"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.ico"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.truevision.tga-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.sgi.sgi-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.ilm.openexr-image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.kodak.flashpix.image"
)
AND
(
NOT ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.composite-content"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.presentation"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio”
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie”
)
)
).@count == $extensionItem.attachments.@count
).@count <=50
有人能指出我正确的方向吗?如果我可以使用SUBQUERY来处理上面给出的规则,那么我基本上可以扩展它以使用其他文件类型。