gpt4 book ai didi

iOS AppExtension : How can I Combine NSExtensionActivationRule and NSPredicate

转载 作者:可可西里 更新时间:2023-11-01 05:03:11 25 4
gpt4 key购买 nike

我目前正在开发一个包含共享扩展的 iOS 应用程序。

我意识到NSExtensionActivationSupportsImageWithMaxCount key 不允许我在 Safari(即:imgur 链接)下激活 .jpeg 或 .png URL(“public.image”UTI,kUTTypeImage)上的共享扩展。

如果我切换到 NSActivationRule = TRUEPREDICATE,我仍然可以激活和测试我的扩展,但它被禁止用于已发布的应用程序。

我在雷达上填写了一个错误,以防万一它不需要(甚至 facebook、twitter 等...都没有在此 URL 上激活)

现在,我想将以下键和“public.image”组合在一个 NSPredicate 字符串中,如文档所述 (https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8)

所以我必须将 key 转换为 UTI

到目前为止我已经翻译了:
- NSExtensionActivationSupportsFileWithMaxCount 到“public.file-url” kUTTTypeFileURL
- NSExtensionActivationSupportsMovieWithMaxCount 到“public.movi​​e”kUTTypeMovie
- NSExtensionActivationSupportsText 到“public.text” kUTTypeText
- NSExtensionActivationSupportsWebURLWithMaxCount 到“public.url” kUTTypeURL

但我找不到类型翻译:

  • NSExtensionActivationSupportsWebPageWithMaxCount,“public.HTML”是 kUTTypeHTML 吗?

有人已经在谓词中使用了这个键吗?

最佳答案

我最终做的是 1) 暂时允许 TRUEPREDICATE,并使用类似这样的逻辑`

    NSExtensionItem *item = extensionContext.inputItems.firstObject;

if ( item )
{
NSItemProvider *itemProvider = item.attachments.firstObject;

if ( itemProvider )
{
NSArray *registeredTypeIdentifiers = itemProvider.registeredTypeIdentifiers;
NSLog( @"registeredTypeIdentifiers: %@", registeredTypeIdentifiers );
}
}`

这将为您提供要共享的文档的所有类型(例如:“public.url”)。由于有多种类型,我的谓词变得有点复杂:

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.plain-text"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
|| 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 "com.compuserve.gif"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.bmp"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.word.doc"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.openxmlformats.wordprocessingml.document"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.comma-separated-values-text"
)
AND
(
NOT ( ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.photoshop-image" )
)

).@count == $extensionItem.attachments.@count
).@count == 1

这基本上会查找图像(adobe psd 除外)、pdf、txt、csv 或 doc/docx 的任何文件类型。它还只允许一次共享 1 个文档。

看起来 kUTTypeImage 包含 PSD - 因此我阻止了该格式(“com.adobe.photoshop-image”)。

关于iOS AppExtension : How can I Combine NSExtensionActivationRule and NSPredicate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26218627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com