Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在Obj-C中过滤多个谓词的最快方法_Objective C_Nspredicate - Fatal编程技术网

Objective c 在Obj-C中过滤多个谓词的最快方法

Objective c 在Obj-C中过滤多个谓词的最快方法,objective-c,nspredicate,Objective C,Nspredicate,我经常做一个冗长的筛选,我想知道以下方法之间的性能是否有任何差异,或者它们是否只是风格问题 NSPredicate *predicate = [NSPredicate predicateWithFormat:@""]; NSPredicate *blockPredicate = [NSPredicate predicateWithBlock:nil]; NSCompoundPredicate *compoundPredicate = [NSCompoundPredicate andPredica

我经常做一个冗长的筛选,我想知道以下方法之间的性能是否有任何差异,或者它们是否只是风格问题

NSPredicate *predicate = [NSPredicate predicateWithFormat:@""];
NSPredicate *blockPredicate = [NSPredicate predicateWithBlock:nil];
NSCompoundPredicate *compoundPredicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[]];
我确实发现另一篇帖子提到了它们是一个风格问题,但它没有讨论
predicateWithBlock
,也没有详细说明这些方法是如何工作的

我还有一个半相关的问题:将谓词传递到NSCompoundPredicate中的速度更快,还是与将它们声明为变量并将变量传递到外部的速度相同?i、 e

NSCompoundPredicate *cp = [NSCompoundPredicate andPredicateWithSubpredicates:
@[[NSPredicate predicateWithFormat:""], [NSPredicate predicateWithFormat:""]];


如果您对此有任何解释,我们将不胜感激,谢谢您

您能确认您所说的是内存过滤吗?核心数据过滤当然不适用于块,但只是为了确保…@jcaron是的,我说的是内存过滤;我没有使用核心数据,你能确认你说的是内存过滤吗?核心数据过滤当然不适用于块,但只是为了确保…@jcaron是的,我说的是内存过滤;我没有使用核心数据
NSCompoundPredicate *cp = [NSCompoundPredicate andPredicateWithSubpredicates:
@[pred1, pred2]];