共享扩展子查询以限制项类型

时间:2016-10-04 14:21:10

标签: ios objective-c nspredicate ios8-share-extension

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

我只想支持images, pdf and url

share extension在所有类型中都可见。即视频,联系人等。

1 个答案:

答案 0 :(得分:1)

这是因为行:

).@count <= 10

它返回true 0,这意味着true没有匹配,因此您的扩展程序将为每种类型返回true。如果要将图像数量限制为10,请将此行更改为以下内容。

).@count == $extensionItem.attachments.@count AND $extensionItem.attachments.@count <= 10"