码迷,mamicode.com
首页 > 其他好文 > 详细

NSPredicate

时间:2017-08-29 20:36:03      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:over   filter   top   item   ora   str   obj   ast   doc   

A definition of logical conditions used to constrain a search either for a fetch or for in-memory filtering.

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 which is parsed by the class methods on NSPredicate. Examples of predicate format strings include:

  • Simple comparisons, such as grade == "7" or firstName like "Shaffiq"

  • Case and diacritic insensitive lookups, such as name contains[cd] "itroen"

  • Logical operations, such as (firstName like "Mark") OR (lastName like "Adderley")

  • Temporal range constraints, such as date between {$YESTERDAY, $TOMORROW}.

  • Relational conditions, such as group.name like "work*"

  • Aggregate operations, such as @sum.items.price < 1000

For a complete syntax reference, refer to the Predicate Programming Guide.

You can also create predicates that include variables using the evaluate(with:substitutionVariables:) method, so that the predicate can be predefined before substituting concrete values at runtime.

NSPredicate

标签:over   filter   top   item   ora   str   obj   ast   doc   

原文地址:http://www.cnblogs.com/feng9exe/p/7449920.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!