在哪里可以找到核心数据的NSPredicate的SUBQUERY特性的文档? [英] Where to find the documentation of the SUBQUERY feature of NSPredicate for Core Data?
问题描述
在哪里可以找到NSPredicate对于核心数据的SUBQUERY特性的文档?
Where to find the documentation of the SUBQUERY feature of NSPredicate for Core Data?
推荐答案
这是我发现的:
- 最多的文档可以在 NSExpression(forSubquery:usingIteratorVariable:predicate :) documentation 。它包含两个示例和语法:
SUBQUERY(collection_expression,variable_expression,predicate);
- NSExpression 简要提及子查询表达式和
NSSubqueryExpressionType
,这是在您的谓词中指定SUBQUERY
时使用的。 - 找到文档的最合理的位置是谓词编程指南,但它只是提到几次;在字符串比较和保留字部分。
- 您可以试试 Google搜索仅限于apple.com ,但只返回53个结果。 >
- 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 specifySUBQUERY
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屋!