Predicate Programming Guide

https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Predicates/AdditionalChapters/Introduction.html#//apple_ref/doc/uid/TP40001789

Predicates provide a general means of specifying queries in Cocoa. The predicate system is capable of handling a large number of domains, including Core Data and Spotlight. This document describes predicates in general, their use, their syntax, and their limitations.

At a Glance

In Cocoa, a predicate is a logical statement that evaluates to a Boolean value (true or false). There are two types of predicate, known as comparison and compound:

  • comparison predicate compares two expressions using an operator. The expressions are referred to as the left hand side and the right hand side of the predicate (with the operator in the middle). A comparison predicate returns the result of invoking the operator with the results of evaluating the expressions.
  • compound predicate compares the results of evaluating two or more other predicates, or negates another predicate.

Cocoa supports a wide range of types of predicate, including the following:

  • Simple comparisons, such as grade == 7 or firstName like ‘Mark‘
  • Case or diacritic insensitive lookups, such as name contains[cd] ‘citroen‘
  • Logical operations, such as (firstName beginswith ‘M‘) AND (lastName like ‘Adderley‘)

You can also create predicates for relationships—such as group.name matches ‘work.*‘ALL children.age > 12, and ANY children.age > 12—and for operations such as @sum.items.price < 1000.

Cocoa predicates provide a means of encoding queries in a manner that is independent of the store used to hold the data being searched. You use predicates to represent logical conditions used for constraining the set of objects retrieved by Spotlight and Core Data, and for in-memory filtering of objects.

You can use predicates with any class of object, but a class must be key-value coding compliant for the keys you want to use in a predicate.

时间: 2024-10-31 13:16:20

Predicate Programming Guide的相关文章

Quartz 2D Programming Guide

Quartz 2D Programming  Guide 官方文档: Quartz 2D Programming Guide 译文: Quartz 2D编程指南(1) - 概览 Quartz 2D编程指南(2) - 图形上下文(Graphics Contexts) Quartz 2D编程指南(3) - 路径(Paths)[上] Quartz 2D编程指南(3) - 路径(Paths)[下] Quartz 2D编程指南(4) - 颜色和颜色空间 Quartz 2D编程指南(5) - 变换 Quar

View Programming Guide for iOS 视图编程指南 - iOS

1 有关 Windows and Views 每个应用都至少有一个 window 和一个 view. 1.1 添加额外的 Window 一般在有外界显示设备的时候才需要添加额外的 window 下面的代码举了一个例子,这里假定对象实现了方法 externalWindow,externalWindow 存储一个 window 的引用 - (void)configureExternalDisplayAndShowWithContent:(UIViewController*)rootVC { // C

Core Bluetooth Programming Guide - Performing Common Peripheral Role Tasks 粗译

Core Bluetooth Programming Guide 粗译 续 code {padding:0.2em 0.4em; background:#e1e9ed;} pre {text-align:left; overflow-x: scroll; color: #d3bd7e; background: #202020; padding: 10pt 15pt; border-radius: 3px;} hr {border: 0px; border-top: 1px solid #ddd;

线程编程指南(Threading Programming Guide)

简介 线程是一种技术,可以在一个应用中同时执行多个代码路径.尽管新技术如操作对象和GCD提供一个更现代和更高效的工具来实现并发,OS X 和iOS也提供接口来创建和管理线程. 本文揭示了OS X中可用的线程包并展示了如何使用它们.本文还描述了应用程序中支持线程和多线程代码同步的相关技术. 重要:如果你正在开发一个新的应用,鼓励你研究实现并发的OS X技术.尤其是你不熟悉实现线程应用所需要的设计技术.这些可选择的技术简化你实现执行并发路径的工作量并提供相对传统线程更好的性能.关于这些技术的信息,参

《OpenGL ES 2.0 Programming Guide》第12章“最简单的ReadPixels并保存为BMP”示例代码【C语言版】

由于<OpenGL ES 2.0 Programming Guide>原书并没有提供第12章的示例代码,书上的代码也只提到关键的步骤,而网上大多是Android/iOS版本的示例,C/C++的大都基于OpenGL或OpenGL ES 3.0,为了加深理解,遂自己实现了一份C语言版本的,希望能够帮助到同样喜欢OpenGL ES 2.0的同学. 废话不多说,直接上代码 #include "stdafx.h" #include "esUtil.h" #incl

Spark1.1.0 Spark Programming Guide

Spark Programming Guide Overview Linking with Spark Initializing Spark Using the Shell Resilient Distributed Datasets (RDDs) Parallelized Collections External Datasets RDD Operations Basics Passing Functions to Spark Working with Key-Value Pairs Tran

Spark1.1.0 Spark Streaming Programming Guide

Spark Streaming Programming Guide Overview A Quick Example Basic Concepts Linking Initializing StreamingContext Discretized Streams (DStreams) Input DStreams Transformations on DStreams Output Operations on DStreams Caching / Persistence Checkpointin

Spark1.1.0 Spark SQL Programming Guide

Spark SQL Programming Guide Overview Getting Started Data Sources RDDs Inferring the Schema Using Reflection Programmatically Specifying the Schema Parquet Files Loading Data Programmatically Configuration JSON Datasets Hive Tables Performance Tuning

Apache Spark 2.2.0 中文文档 - GraphX Programming Guide | ApacheCN

GraphX Programming Guide 概述 入门 属性 Graph 示例属性 Graph Graph 运算符 运算符的汇总表 Property 运算符 Structural 运算符 Join 运算符 邻域聚合 聚合消息 (aggregateMessages) Map Reduce Triplets Transition Guide (Legacy) 计算级别信息 收集相邻点 Caching and Uncaching Pregel API Graph 建造者 Vertex and E