iOS 探讨之 NSPredicate构造 之 格式字符串

本文深入探讨了iOS开发中的谓词NSPredicate,重点解析如何使用格式字符串创建谓词,揭示其在数据过滤和查询中的关键作用。
摘要由CSDN通过智能技术生成
阐述
提升产品的性能,一方面可以从界面构造上入手,另一方面可以从业务数据处理上进行入手。 
业务数据处理优化中,数据的筛选是很大一部分,这个过程中遇见了”NSPredicate”,感觉这个东西很不错,初步了解并记录一下,毕竟东西有点多。


探讨

1 谓词是什么

Predicate 翻译过来,是谓词的意思。

在百度中,对谓词描述如下: 
谓词,用来描述或判定客体性质、特征或者客体之间关系的词项。
谓词:在计算机语言的环境下,谓词是指条件表达式的求值返回真或假的过程。


在Apple官方文档,对NSPredicate的描述如下:
A definition of logical conditions used to constrain a search either for a fetch or for in-memory filtering.
一种逻辑的定义,这种逻辑用于约束一个搜索条件,这个搜索条件可以用于数据的获取或者是内存数据的筛选.

2 谓词分哪几类
谓词分为两类 Comparision(比较) 和 Compound(混合) 。
官方文档中对种类的描述:
* A 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.
* A compound predicate compares the results of evaluating two or more other predicates, or negates another predicate.

大致意思:
比较谓词用操作符来评估比较两个表达式。这两个表达式一个在操作符的左侧,一个在操作符的右侧。比较谓词返回的是内部操作符与相关语句执行的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值