我希望我的扩展程序支持文字,网址,视频和10张图片。
这项工作正常,但我希望我的扩展程序不同时支持图像和视频。
我知道我很可能不得不建立一个" SUBQUERY(..)"声明。 我的谓词是这样的:
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,(
NOT ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
AND ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie")
) AND (
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text")
).@count < 10
).@count == 1
但它对我不起作用。在这种情况下我该如何使用。谢谢你的帮助!
答案 0 :(得分:0)
您不需要构建子查询。在您的扩展的info.plist中将有NSExtension。并且它将NSExtension作为truepredicate。编辑该plist文件并添加NSExtensionActivationRule。添加相应的密钥。有关密钥详情click here
答案 1 :(得分:0)
尝试使用此工具共享有限的图片,文档和视频
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.mpeg-4"
).@count == 0).@count == 1
AND
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
).@count <= 15).@count >= 1
AND
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,(
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.waveform-audio"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data"
AND NOT ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
)
).@count <= 3
).@count == 1
答案 2 :(得分:0)
这是我刚刚为自己使用的一个。这仅允许一项,任何视频类型或任何图像类型。我从苹果公司的documentation修改了一个示例。
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie"
).@count == 1
).@count == 1
为了易于使用,直接复制到plist中:
SUBQUERY (extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" || ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ).@count == 1).@count == 1
答案 3 :(得分:0)
您可以使用Parth Adroja的答案基于特定数量共享图像或视频。在我的特定情况下,该扩展程序应该共享4张图像或1个视频,并且它们是互斥的。
这就是我所做的。
float renderDroplets(int waterAmounnt) {
int numOfDroplets = int(waterAmount / 12.5)
renderFullDroplets(numOfDroplets)
float remainingWater = int(waterAmount % 12.5)
if (remainingWater >= 6.5) {
renderHalfDroplet();
} else {
renderEmptyDroplet();
}
}