【发布时间】:2014-10-29 11:21:31
【问题描述】:
当我们使用 ALL/ANY 等时,我正在尝试理解 NSPredicate 及其语法
我的班级人:
@interface Person : NSObject
@property (nonatomic, strong) NSString* name;
@property (nonatomic, strong) NSString* surname;
@property NSUInteger age;
@property NSUInteger weight;
@property NSUInteger height;
我将它用于这样的谓词:
NSArray* persons = [NSArray arrayWithObjects:personOne, personTwo, personThree, personFour, nil];
我的谓词:
NSPredicate* predicateEight = [NSPredicate predicateWithFormat:@"ANY SELF.age > %@", @55];
filteredArray = [persons filteredArrayUsingPredicate:predicateEight];
NSLog(@"Age > 55 %@", filteredArray);
我收到了一个错误:
ALL 或 ANY 运算符的左侧必须是 NSArray 或 NSSet
我需要如何更改我的代码? 提前感谢您的帮助。
【问题讨论】:
标签: ios nspredicate