http://blog.csdn.net/lmf208/article/details/38345321
http://blog.csdn.net/jiangwei0910410003/article/details/41923507
如果是两个 存储自定义 对象的数组 直接 进行过滤 。。
#import <Foundation/Foundation.h>
@interface person : NSObject
@property (nonatomic,strong) NSString *num;
@property (nonatomic,strong) NSString *name;
+ (instancetype)personWithNum:(NSString *)num name:(NSString *)name;
@end
初始化 自己自定义的实力 , 并放在不同的两个数组中
person *a1 = [person personWithNum:@"1" name:@"我0"];
person *a2 = [person personWithNum:@"2" name:@"我1"];
person *a3 = [person personWithNum:@"3" name:@"我2"];
person *a4 = [person personWithNum:@"1" name:@"我0"];
person *a5 = [person personWithNum:@"5" name:@"我4"];
person *a6 = [person personWithNum:@"6" name:@"我5"];
person *a7 = [person personWithNum:@"7" name:@"我6"];
person *a8 = [person personWithNum:@"8" name:@"我7"];
NSArray *array1 = [NSArray arrayWithObjects:a1,a2,a3,a8, nil];
NSArray *array2 = [NSArray arrayWithObjects:a3,a4,a5,a6,a7,a1, nil];
//使用第一个数组 来过滤 第二个数组 SELF.num IN %@.num 判断两个数组中 如果有 对象 num 相同的 就 保存到 result 数组中。
// NOT ( SELF.num IN %@.num) //就是 对上面的结果 取反
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.num IN %@.num",array1];
NSArray *result = [array2 filteredArrayUsingPredicate:predicate];
NSLog(@"%@",result);