Overview
概要
Predicates represent logical conditions, which you can use to filter collections of objects. Although it’s common to create predicates directly from instances of NSComparisonPredicate
, NSCompoundPredicate
, and NSExpression
, you often create predicates from a format string that the class methods parse on NSPredicate
. Examples of predicate format strings include:
述部は論理条件を表します、それはあなたがオブジェクトのコレクションをフィルタするのに使用できます。普通は述部をNSComparisonPredicate
、NSCompoundPredicate
、そしてNSExpression
のインスタンスから直接に作成するとはいえ、あなたはしばしば述部それらをある書式設定文字列から作成します、それはクラスメソッドがNSPredicate
上で構文解析します。述部書式設定文字列の例は以下を含みます:
Simple comparisons, such as grade == “7”
or firstName like “Juan”
単純な比較、例えばgrade == “7”
またはfirstName like “Juan”
Case- and diacritic-insensitive lookups, such as name contains[cd] “stein”
ケースおよび区別的発音符に配慮しない検索、例えばname contains[cd] “stein”
Logical operations, such as (firstName like “Mei”) OR (lastName like “Chen”)
論理演算、例えば(firstName like “Mei”) OR (lastName like “Chen”)
Temporal range constraints, such as date between {$YESTERDAY, $TOMORROW}
時を表す範囲の制約、例えばdate between {$YESTERDAY, $TOMORROW}
Relational conditions, such as group.name like “work*"
関係条件、例えばgroup.name like “work*"
Aggregate operations, such as @sum.items.price < 1000
集合演算、例えば@sum.items.price < 1000
For a complete syntax reference, refer to the Predicate Programming Guide.
完全な構文参照のために、Predicate Programming Guideを参照してください。
You can also create predicates that include variables using the evaluate(with:substitutionVariables:)
method so that you can predefine the predicate before substituting concrete values at runtime.