NSPredicate匹配多个属性

Cry*_*tal 1 iphone nspredicate

我已经考虑过在我的应用程序中过滤我的数据,我得到了一个建议,看看NSPredicate.我一直在用其中一本Apress书籍来研究它,但我遇到了一个问题,所以我试图创建一个.

如果我有这样的事情:

myObject : NSObject
@property (nonatomic, retain) NSString *firstName;
@property (nonatomic, retain) NSString *lastName;
@property (nonatomic, assign) NSInteger age;
Run Code Online (Sandbox Code Playgroud)

创建一些对象然后放入一个数组.

然后我不确定如何创建搜索的预测

Rol*_*asR 5

它很简单

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(firstName == %@) || (lastName == %@) || (age == %i)", <name>, <lastName>, <age>];