我正在尝试归档此对象的数组:
我的对象.h
@interface MyObject : NSObject
@property (assign) int id_object;
@property (nonatomic, strong) NSString *name;
@end
因此,例如在我的 firstArray 中,我有一些 MyObject:
MyObject *ob1 = [[MyObject alloc] init];
[ob1 setId_Object:1;
[ob1 setName:@"Carl"];
MyObject *ob2 = [[MyObject alloc] init];
[ob2 setId_Object:2;
[ob2 setName:@"Carl"];
MyObject *ob3 = [[MyObject alloc] init];
[ob3 setId_Object:3;
[ob3 setName:@"Carl"];
NSArray *firstArray = [[NSArray alloc] initWithObjects:ob1,ob2,ob3,nil];
然后我想用 NSPredicate 和一个 NSNumber 数组过滤这个数组,像这样:
NSArray *secondArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],nil];
我试过这个:
NSArray *filteredObject = [firstArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"id_object IN %@",secondArray]];
但是filteredObject是空的,我该怎么办?