iOS Share extension how to support *.wav files

我与影子孤独终老i 提交于 2019-12-01 09:50:09
LostBalloon

I ended up doing the following:

for the NSExtensionActivationRule key, I changed the type from Dictionary to String and entered the following string (you can keep the formatting, doesn't need to be all inline):

SUBQUERY (
    extensionItems,
    $extensionItem,
    SUBQUERY (
        $extensionItem.attachments,
        $attachment,
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio"
    ).@count == $extensionItem.attachments.@count
).@count >= 1

You only need the:

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

but my extension also supports movies and images which is why it has those too (left it in for those that may be curious how to support more than one. Note that I've decided to support more audio options than just waves as I was initially inquiring about. The types can be looked up here: Uniform Type Identifiers Reference

The first count check makes sure that every single selected item in the host app conforms with the extension.

The second count check, the one at the end is used to indicate that the extension accepts 1 or more items (that conform). If you wanted to only allow for 1 item at the time to be processed by your extension you would enter the following:

).@count == 1

or, if you wanted to allow for multiple items with an upper limit:

).@count < 4

or

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