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]];