在哪里可以找到核心数据的NSPredicate的SUBQUERY特性的文档? [英] Where to find the documentation of the SUBQUERY feature of NSPredicate for Core Data?

查看:167
本文介绍了在哪里可以找到核心数据的NSPredicate的SUBQUERY特性的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到NSPredicate对于核心数据的SUBQUERY特性的文档?

Where to find the documentation of the SUBQUERY feature of NSPredicate for Core Data?

推荐答案

这是我发现的:

  • The most documentation can be found at NSExpression(forSubquery:usingIteratorVariable:predicate:) documentation. It contains two examples and the syntax: SUBQUERY(collection_expression, variable_expression, predicate);
  • NSExpression briefly mentions Subquery Expressions and the NSSubqueryExpressionType, which is what is used when you specify SUBQUERY in your predicate.
  • The most logical place to find the documentation would be the Predicate Programming Guide, but it is just mentioned a few times; in the String Comparisons, and the Reserved Words sections.
  • You can try a Google search limited to apple.com, but this only returns 53 results.

更新:

,Apple已包含更多SUBQUERY示例,因为它们是复杂匹配逻辑所需的。

With the addition of App Extensions, Apple has included more SUBQUERY examples since they are required for complex matching logic.

  • In the String Comparisons section of the Predicate Programming Guide, it now includes an example of how to match a UTI:

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


  • 您可以在应用扩展程序编程指南>应用扩展程序基本要素> 处理常见情况部分:

    SUBQUERY (
        extensionItems,
        $extensionItem,
        SUBQUERY (
            $extensionItem.attachments,
            $attachment,
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.action-one" ||
            ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "org.appextension.action-two"
        ).@count == $extensionItem.attachments.@count
    ).@count == 1
    


  • 还有 NSPredicate Cheatsheet 除了几个其他NSPredicate功能之外,还讨论SUBQUERY。

  • There's also an NSPredicate Cheatsheet which discusses SUBQUERY in addition to several other NSPredicate features.

    基本上每个 SUBQUERY 等效于过滤器在Swift中。 ANY 等效于包含

    Essentially each SUBQUERY is equivalent to filter in Swift. And ANY is equivalent to contains.

    此示例再次:

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

    Swift:

    extensionItems.filter {
      $0.attachments.filter {
        $0.registeredTypeIdentifiers.contains {
          $0.utiConformsTo("com.adobe.pdf")
        }
      }.count == $0.attachments.count
    }.count == 1
    

    这篇关于在哪里可以找到核心数据的NSPredicate的SUBQUERY特性的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆